Exit the main loop, not the current one, on unhandled exception

If wxApp::OnExceptionInMainLoop() returns false, we're supposed to exit
the application by stopping its main event loop, not the loop that is
currently running, so do the former instead of the latter.

Also call wxAbort() if we can't exit the application in any other way,
this is not ideal, but still better than not doing anything and, for
example, keeping showing the same "Unexpected error occurred" message
box to the user over and over again if the exception comes from an event
handler being called repeatedly, such as wxEVT_PAINT or wxEVT_IDLE.
This commit is contained in:
Vadim Zeitlin
2018-01-17 11:47:08 +01:00
parent 1dd102d741
commit 4750e1ee78

View File

@@ -1635,8 +1635,21 @@ void wxEvtHandler::WXConsumeException()
{
if ( !wxTheApp || !wxTheApp->OnExceptionInMainLoop() )
{
if ( loop )
loop->Exit();
// If OnExceptionInMainLoop() returns false, we're supposed to exit
// the program and for this we need to exit the main loop, not the
// possibly nested one we're running right now.
if ( wxTheApp )
{
wxTheApp->ExitMainLoop();
}
else
{
// We must not continue running after an exception, unless
// explicitly requested, so if we can't ensure this in any
// other way, do it brutally like this.
wxAbort();
}
}
//else: continue running current event loop
}