On Mon, Feb 24, 2014 at 8:09 AM, Staffan Tylen <staffan.tylen@gmail.com> wrote:

2. What is a DialogProxy? I get the following when pressing OK after reaching the limit above:


Hi Staffan,

To follow up with this a little.  Each open dialog uses up a relatively large block of  memory.  The original ooDialog developers set this limit of 20 maximum dialogs open at any one time.

If you attempt to create the 21st dialog, the interpreter returns an object, but it does not have that backing block of memory.  If you then invoked a method on the object that needed to access the backing block, it would crash the interpreter.  The initCode of the returned object would always be non-zero.

If it could be counted on that every user would check the initCode every time, then things would be okay.  In your program, if you checked the initCode attribute before you popped up the dialog and didn't try to use the dialog if the initCode was not zero, you never would have had a syntax condition raised.

For example:

  dialogs = .array~new(40)
  do i = 1 to 35
    dlg = .SimpleRcDlg~new("simple.rc", IDD_SIMPLE_DLG, , "simple.h" )
    if dlg~initCode <> 0 then do
      say 'Failed to create dialog number' i'.  Going to stop dialog creation.'
      leave
    end

    dlg~popup("SHOWTOP", IDI_DLG_OOREXX)
    dialogs[i] = dlg
  end

works fine because it does not try to pop up the dialog if the initCode is not 0.  You never would have seen this error:
 
Error 97.1:  Object "a DialogProxy" does not understand message "POPUPASCHILD"


On the other hand, as you demonstrated, we can not really count on every one checking the initCode attribute.  The DialogProxy, provides an object to return when the maximum number of dialogs is reached.  It has an initCode attribute that is never 0, and no other methods.  If you check the initCode, then all is fine.  If you don't check the initCode, then no method is invoked that will crash the interpreter, and all is still fine.

--
Mark Miesfeld