diff --git a/include/wx/log.h b/include/wx/log.h index 775fac228f..c7bbf0b2db 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -606,6 +606,13 @@ private: static bool EnableThreadLogging(bool enable = true); #endif // wxUSE_THREADS + // get the active log target for the main thread, auto-creating it if + // necessary + // + // this is called from GetActiveTarget() and OnLog() when they're called + // from the main thread + static wxLog *GetMainThreadActiveTarget(); + // called from OnLog() if it's called from the main thread or if we have a // (presumably MT-safe) thread-specific logger and by FlushThreadMessages() // when it plays back the buffered messages logged from the other threads diff --git a/src/common/log.cpp b/src/common/log.cpp index d3595d1234..e0e0c03eea 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -294,7 +294,7 @@ wxLog::OnLog(wxLogLevel level, else #endif // wxUSE_THREADS { - logger = ms_pLogger; + logger = GetMainThreadActiveTarget(); if ( !logger ) return; } @@ -464,6 +464,12 @@ wxLog *wxLog::GetActiveTarget() } #endif // wxUSE_THREADS + return GetMainThreadActiveTarget(); +} + +/* static */ +wxLog *wxLog::GetMainThreadActiveTarget() +{ if ( ms_bAutoCreate && ms_pLogger == NULL ) { // prevent infinite recursion if someone calls wxLogXXX() from // wxApp::CreateLogTarget()