Hi Antonio,
I think I found a possible issue in the current FiveWin sources (FW 26.xx).
My application uses MDI windows and I open child dialogs using:
ACTIVATE DIALOG oDlg CENTERED NOWAIT
The dialogs are modeless and each one works with its own ADODB.Recordset.
When the dialog is closed, the Recordset is closed correctly. However, after the dialog has already been destroyed, FiveWin still evaluates all the WHEN clauses.
After some debugging I found the following execution sequence:
TBtnFlat:Click()
Eval( ::bAction ) // oDlg:End()
::Super:Click()
TControl:Click()
::oContainerWnd:AEvalWhen()The problem is that after oDlg:End(), the dialog handle is already destroyed (hWnd == 0), but AEvalWhen() is still called.
As a consequence, every control's WHEN block is evaluated again, for example:
WHEN oRs:RecordCount() == 0
Since the ADODB.Recordset has already been closed, this raises an exception.
I tested the following modification in TControl:
METHOD Click() CLASS TControl
if ::oContainerWnd != nil .and. ::oContainerWnd:hWnd != 0
::oContainerWnd:AEvalWhen()
endif
return nil
(or the equivalent INLINE version)
After this change:
the exception disappears;
all my dialogs continue to work correctly;
AEvalWhen() is no longer executed for a dialog that has already been destroyed.
It seems that AEvalWhen() should not be called after the dialog has been closed, because there are no controls left to update and any WHEN block may access objects that have already been released (such as ADODB.Recordsets).
Could you please check whether this behavior is intentional, or if the hWnd test should be added before calling AEvalWhen()?
Thank you.
Maurizio
www.nipeservice.com