lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Catching exceptions thrown in OnInit()


From: Vadim Zeitlin
Subject: Re: [lmi] Catching exceptions thrown in OnInit()
Date: Wed, 28 Jun 2006 20:43:10 +0200

On Wed, 28 Jun 2006 17:03:17 +0000 Greg Chicares <address@hidden> wrote:

GC> Vadim--In OnInit(), I'm doing some things that can throw exceptions.
GC> I observe that my overridden OnUnhandledException() handles them;

 Indeed, the implementation of OnUnhandledException() was changed since
this comment had been written and now it also catches exceptions thrown
from OnInit() and OnExit().

GC> First, for wxmsw at least, I can demonstrate with ::MessageBox()
GC> calls that OnUnhandledException() handles exceptions thrown in
GC> OnInit() as well as in OnRun(). Does that sound right?

 Yes, absolutely.

GC> Second, and subject to the same disclaimers, I think that the advice
GC> to insert try and catch into OnRun() should apply to OnInit(), too.

 Yes, I'll correct the comment, thanks.

GC> One change I certainly must make anyway is in my safe-messagebox
GC> function for msw:
GC> 
GC>     HWND handle = 0;
GC>     wxWindow* top_window = wxTheApp->GetTopWindow();
GC>     if(top_window)
GC>         handle = reinterpret_cast<HWND>(top_window->GetHandle());
GC>     ::MessageBox(handle, message, "Error", MB_OK | MB_ICONSTOP | 
MB_TASKMODAL);
GC> 
GC> which clearly should check whether wxTheApp is null before trying
GC> to dereference it.

 Yes, certainly. I think you can safely use NULL as parent HWND here anyhow
because you use MB_TASKMODAL style which, I believe, ignores this argument.

 Regards,
VZ





reply via email to

[Prev in Thread] Current Thread [Next in Thread]