Access to Forms just being created

delphi package - automated exception handling

Access to Forms just being created

Postby Sneak-L8 » Tue Apr 18, 2017 4:59 pm

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
Sneak-L8
 
Posts: 6
Joined: Tue Apr 18, 2017 3:43 pm

Re: Access to Forms just being created

Postby madshi » Tue Apr 18, 2017 5:11 pm

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?
madshi
Site Admin
 
Posts: 9338
Joined: Sun Mar 21, 2004 5:25 pm

Re: Access to Forms just being created

Postby Sneak-L8 » Wed Apr 19, 2017 10:30 am

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
Sneak-L8
 
Posts: 6
Joined: Tue Apr 18, 2017 3:43 pm

Re: Access to Forms just being created

Postby madshi » Wed Apr 19, 2017 10:46 am

That seems weird. What's the callstack on the Destroy breakpoint with madExcept enabled vs disabled?
madshi
Site Admin
 
Posts: 9338
Joined: Sun Mar 21, 2004 5:25 pm

Re: Access to Forms just being created

Postby Sneak-L8 » Wed Apr 19, 2017 10:58 am

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)
Sneak-L8
 
Posts: 6
Joined: Tue Apr 18, 2017 3:43 pm

Re: Access to Forms just being created

Postby madshi » Wed Apr 19, 2017 11:00 am

Hmmmm... The Destroy method is called from within your exception handler (when not using madExcept)?
madshi
Site Admin
 
Posts: 9338
Joined: Sun Mar 21, 2004 5:25 pm

Re: Access to Forms just being created

Postby Sneak-L8 » Wed Apr 19, 2017 11:04 am

Yes, within Form.ShowModal (presumably when performing an internal Application.ProcessMessages)
Sneak-L8
 
Posts: 6
Joined: Tue Apr 18, 2017 3:43 pm

Re: Access to Forms just being created

Postby madshi » Wed Apr 19, 2017 12:21 pm

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?
madshi
Site Admin
 
Posts: 9338
Joined: Sun Mar 21, 2004 5:25 pm

Re: Access to Forms just being created

Postby Sneak-L8 » Wed Apr 19, 2017 6:05 pm

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?
Sneak-L8
 
Posts: 6
Joined: Tue Apr 18, 2017 3:43 pm

Re: Access to Forms just being created

Postby madshi » Wed Apr 19, 2017 8:27 pm

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.
madshi
Site Admin
 
Posts: 9338
Joined: Sun Mar 21, 2004 5:25 pm

Re: Access to Forms just being created

Postby Sneak-L8 » Wed Apr 19, 2017 9:52 pm

Hey, great. It works! Now, the form is still there when gathering additional DB information.

Thanks!

Bye
Sneak-L8
Sneak-L8
 
Posts: 6
Joined: Tue Apr 18, 2017 3:43 pm


Return to madExcept

Who is online

Users browsing this forum: No registered users and 4 guests

cron