From a20844525f329c8387191dbde0eab86693412851 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 4 Sep 2009 00:27:51 +0000 Subject: [PATCH] Fix regression with logging messages during wxApp initialization. Changes in r61450 broke logging of the messages for errors occurring during wxApp initialization, such as the message about the failure to establish connection to the X server. Instead of being shown on stderr, wxLogGui was used resulting in a crash. Creating wxLogOutputBest in wxLog code before wxTheApp creation was not enough as this error occurred after wxTheApp creation -- but before it became usable. Fix this by explicitly asking wxLog to instantiate a safe log target in DoCommonPreInit() if the user hadn't set up his own yet and using it until the GUI is fully initialized. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61825 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/init.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/common/init.cpp b/src/common/init.cpp index cf36649317..aca0a83306 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -221,6 +221,21 @@ static bool DoCommonPreInit() #if wxUSE_LOG // Reset logging in case we were cleaned up and are being reinitialized. wxLog::DoCreateOnDemand(); + + // force wxLog to create a log target now: we do it because wxTheApp + // doesn't exist yet so wxLog will create a special log target which is + // safe to use even when the GUI is not available while without this call + // we could create wxApp in wxEntryStart() below, then log an error about + // e.g. failure to establish connection to the X server and wxLog would + // send it to wxLogGui (because wxTheApp does exist already) which, of + // course, can't be used in this case + // + // notice also that this does nothing if the user had set up a custom log + // target before -- which is fine as we want to give him this possibility + // (as it's impossible to override logging by overriding wxAppTraits:: + // CreateLogTarget() before wxApp is created) and we just assume he knows + // what he is doing + wxLog::GetActiveTarget(); #endif // wxUSE_LOG return true; -- 2.45.2