From bcacb4467e2735f5fb2ac2bf30f7e06dd7ab7d64 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 9 Mar 2015 19:41:50 +0100 Subject: [PATCH] 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). --- src/generic/logg.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/generic/logg.cpp b/src/generic/logg.cpp index 3db08ecb42..902845f7f4 100644 --- a/src/generic/logg.cpp +++ b/src/generic/logg.cpp @@ -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