lmi
[Top][All Lists]
Advanced

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

Re: [lmi] Overriding OnAssertFailure()


From: Vadim Zeitlin
Subject: Re: [lmi] Overriding OnAssertFailure()
Date: Sun, 26 Oct 2014 14:17:53 +0100

On Sun, 26 Oct 2014 01:23:03 +0000 Greg Chicares <address@hidden> wrote:

GC> I finally took your suggestion here:
GC> 
GC>   http://lists.nongnu.org/archive/html/lmi/2007-11/msg00002.html
GC> | so you may want to override wxApp::OnAssertFailure().
GC> 
GC> Committed 20141026T0104Z, revision 5998. [As the comments in the
GC> changed code explain, I think this will prevent user confusion.]

 Yes, I definitely agree this will be helpful if an assert ever fails.

GC> But I'm confused about ShowAssertDialog() in src/common/appbase.cpp :
GC> 
GC>    1369 #if wxUSE_THREADS
GC>    1370     // if we are not in the main thread, output the assert directly 
and trap
GC>    1371     // since dialogs cannot be displayed
GC>    1372     if ( !wxThread::IsMain() )
GC>    1373     {
GC>    1374         msg += wxString::Format(" [in thread %lx]", 
wxThread::GetCurrentId());
GC>    1375     }
GC>    1376 #endif // wxUSE_THREADS
GC> 
GC> The code seems merely to append some string data. But the comment seems
GC> to suggest that the subsequent call to [Do]ShowAssertDialog() would be
GC> blocked, yet that doesn't seem to be the case. What am I missing?

 Sorry for the confusion, the comment became outdated after the changes of
https://github.com/wxWidgets/wxWidgets/commit/2d8e0096 and it just went
unnoticed until now. I'm going to simply remove it when I push out my other
pending changes to wxWidgets soon.

GC> I ask because, even though lmi currently does not use threads, I don't
GC> want my OnAssertFailure() override to make it thread-unsafe.

 The only thing to keep in mind is that OnAssertFailure() can be called not
only in the main thread context if the application uses threads. And as
wxWidgets UI-related functionality can only be safely used from the main
thread, you're limited to using MSW native ::MessageBox() function if you
want to show a dialog from OnAssertFailure() -- but this, of course, is
already exactly what safe_message_alert() does (in its wx variant), so I'm
just repeating things you already know.


 Thanks for noticing this outdated comment!
VZ

reply via email to

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