From 1cdaa5f25111febb2959f6673378de99af47c8e4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 19 May 2013 12:38:22 +0000 Subject: [PATCH] Trigger wxLog auto-creation when getting old logger in wxLogChain ctor. This ensures that a program that uses wxLogChain or one of the classes deriving from it, such as wxLogWindow, can do it directly without worrying about the standard logging being completely suppressed if the default log target hadn't been instantiated yet. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74031 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/log.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/common/log.cpp b/src/common/log.cpp index 5135eadaa3..53ce213b50 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -902,7 +902,14 @@ wxLogChain::wxLogChain(wxLog *logger) m_bPassMessages = true; m_logNew = logger; - m_logOld = wxLog::SetActiveTarget(this); + + // Notice that we use GetActiveTarget() here instead of directly calling + // SetActiveTarget() to trigger wxLog auto-creation: if we're created as + // the first logger, we should still chain with the standard, implicit and + // possibly still not created standard logger instead of disabling normal + // logging entirely. + m_logOld = wxLog::GetActiveTarget(); + wxLog::SetActiveTarget(this); } wxLogChain::~wxLogChain() -- 2.45.2