Make wxLogGui::Flush() exception safe.

Don't suspend the logs forever if showing the log dialog throws an exception
(this is unlikely but may happen when running unattended GUI tests or using
the dialog hooks throwing exceptions for any other purpose).
This commit is contained in:
Vadim Zeitlin
2015-03-09 19:41:50 +01:00
parent 7048b7ec4a
commit bcacb4467e

View File

@@ -51,6 +51,7 @@
#include "wx/collpane.h"
#include "wx/arrstr.h"
#include "wx/msgout.h"
#include "wx/scopeguard.h"
#ifdef __WXMSW__
// for OutputDebugString()
@@ -309,6 +310,10 @@ void wxLogGui::Flush()
// showing right now: nested modal dialogs make for really bad UI!
Suspend();
// and ensure that we allow showing the log again afterwards, even if an
// exception is thrown
wxON_BLOCK_EXIT0(wxLog::Resume);
if ( nMsgCount == 1 )
{
// make a copy before calling Clear()
@@ -331,9 +336,6 @@ void wxLogGui::Flush()
DoShowMultipleLogMessages(messages, severities, times, title, style);
}
// allow flushing the logs again
Resume();
}
// log all kinds of messages