Access to Forms just being created
Access to Forms just being created
Hi,
the name of the topic sounds strange, but I don't know how to express it a better way
Before using madExcept, I had my own ExceptionHandler established in Application.OnException. When I created a new form or dialog and there was an error inside the constructor Create, I was able to find this form in my exception handler via FindComponent.
When using madExcept I do not find this form anymore. I see hat everythings looks like before using madExcept except that the form has gone.
I think the form is already freed when madExcept takes over. Is there a possibility to have the same behaviour like OnException, so the form is not yet freed? I already tried to use stDontSync and stTrySyncCallOnSuccess with no change.
Bye
Sneak-L8
P.S. newest madExcept 4.0.17 and Delphi 7.1
the name of the topic sounds strange, but I don't know how to express it a better way
Before using madExcept, I had my own ExceptionHandler established in Application.OnException. When I created a new form or dialog and there was an error inside the constructor Create, I was able to find this form in my exception handler via FindComponent.
When using madExcept I do not find this form anymore. I see hat everythings looks like before using madExcept except that the form has gone.
I think the form is already freed when madExcept takes over. Is there a possibility to have the same behaviour like OnException, so the form is not yet freed? I already tried to use stDontSync and stTrySyncCallOnSuccess with no change.
Bye
Sneak-L8
P.S. newest madExcept 4.0.17 and Delphi 7.1
Re: Access to Forms just being created
The timing should not change. If the form was still there in Application.OnException, then it should also still be there in your madExcept exception handler.
Can you set a breakpoint in your form's OnDestroy handler to see if it gets called, with both madExcept enabled and disabled? Just to double check?
Can you set a breakpoint in your form's OnDestroy handler to see if it gets called, with both madExcept enabled and disabled? Just to double check?
Re: Access to Forms just being created
Thanks. Testing by breakpointing Destroy was a good idea.
But, unfortunately behaviour differs between Application.OnException and madExcept. Using OnException the form is freed after the error form was created. Using madExcept the form is freed before my registered ExceptionHandler is called.
Is the a "Application.ProcessMessages" in you code with leads the form to be freed?
Bye
Sneak-L8
But, unfortunately behaviour differs between Application.OnException and madExcept. Using OnException the form is freed after the error form was created. Using madExcept the form is freed before my registered ExceptionHandler is called.
Is the a "Application.ProcessMessages" in you code with leads the form to be freed?
Bye
Sneak-L8
Re: Access to Forms just being created
That seems weird. What's the callstack on the Destroy breakpoint with madExcept enabled vs disabled?
Re: Access to Forms just being created
With madExcept:
- TTGUserListEditDlg.Destroy
- TG (name of the project)
Without:
- TTGUserListEditDlg.Destroy
- TErrorForm.HandleException (initial class method of my exception handler)
- TTGMainForm.ApplException (method Application.OnException is assigned to)
- TG (name of the project)
- TTGUserListEditDlg.Destroy
- TG (name of the project)
Without:
- TTGUserListEditDlg.Destroy
- TErrorForm.HandleException (initial class method of my exception handler)
- TTGMainForm.ApplException (method Application.OnException is assigned to)
- TG (name of the project)
Re: Access to Forms just being created
Hmmmm... The Destroy method is called from within your exception handler (when not using madExcept)?
Re: Access to Forms just being created
Yes, within Form.ShowModal (presumably when performing an internal Application.ProcessMessages)
Re: Access to Forms just being created
So basically it's just a timing problem and the form gets destroyed the first time when messages are handled, and without madExcept that just happens to be after your exception handler code has had the chance to run, while with madExcept enabled, for some reason messages seem to be handled before your handler had a chance to run?
Re: Access to Forms just being created
Yes, that's the point. Is there a way to do my handling things before ProcessMessages is performed? Or you even issue an Application.ProcessMessages?
Re: Access to Forms just being created
When using the very latest madExcept build, you can set "madExcept.HandleMessagesInMainThread := false" in your initialization. However, doing so will make your VCL forms all appear frozen, as long as the madExcept exception handling is active.
Re: Access to Forms just being created
Hey, great. It works! Now, the form is still there when gathering additional DB information.
Thanks!
Bye
Sneak-L8
Thanks!
Bye
Sneak-L8