From e94cd97dd7db345ab4c9abb911cf4396fcac3335 Mon Sep 17 00:00:00 2001 From: David Elliott Date: Fri, 18 May 2007 21:17:06 +0000 Subject: [PATCH] Add a wxLog::DoCreateOnDemand and call it from DoCommonPreInit so that logging will work even if wxWidgets is reentered after being cleaned up. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46117 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/log.h | 3 +++ src/common/init.cpp | 3 +++ src/common/log.cpp | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/include/wx/log.h b/include/wx/log.h index 089e21f8ea..c547984bb9 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -181,6 +181,9 @@ public: // current is NULL? static void DontCreateOnDemand(); + // Make GetActiveTarget() create a new log object again. + static void DoCreateOnDemand(); + // log the count of repeating messages instead of logging the messages // multiple times static void SetRepetitionCounting(bool bRepetCounting = true) diff --git a/src/common/init.cpp b/src/common/init.cpp index bb5693e4a9..639a614add 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -220,6 +220,9 @@ static void FreeConvertedArgs() static bool DoCommonPreInit() { #if wxUSE_LOG + // Reset logging in case we were cleaned up and are being reinitialized. + wxLog::DoCreateOnDemand(); + // install temporary log sink: we can't use wxLogGui before wxApp is // constructed and if we use wxLogStderr, all messages during // initialization simply disappear under Windows diff --git a/src/common/log.cpp b/src/common/log.cpp index 8c477ef29c..1604899a58 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -575,6 +575,11 @@ void wxLog::DontCreateOnDemand() ClearTraceMasks(); } +void wxLog::DoCreateOnDemand() +{ + ms_bAutoCreate = true; +} + void wxLog::RemoveTraceMask(const wxString& str) { int index = ms_aTraceMasks.Index(str); -- 2.45.2