X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/04662def27c4227f8372084167e3a37729c048b9..81b32ce52247c45d278507ebeb532e2535bbe186:/src/common/log.cpp diff --git a/src/common/log.cpp b/src/common/log.cpp index 182246bdb0..b577f27aef 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -159,17 +159,22 @@ IMPLEMENT_LOG_FUNCTION(Message) IMPLEMENT_LOG_FUNCTION(Info) IMPLEMENT_LOG_FUNCTION(Status) +void wxSafeShowMessage(const wxString& title, const wxString& text) +{ +#ifdef __WINDOWS__ + ::MessageBox(NULL, text, title, MB_OK | MB_ICONSTOP); +#else + wxFprintf(stderr, _T("%s: %s\n"), title.c_str(), text.c_str()); +#endif +} + // fatal errors can't be suppressed nor handled by the custom log target and // always terminate the program void wxVLogFatalError(const wxChar *szFormat, va_list argptr) { wxVsnprintf(s_szBuf, s_szBufSize, szFormat, argptr); -#if wxUSE_GUI - wxMessageBox(s_szBuf, _("Fatal Error"), wxID_OK | wxICON_STOP); -#else - fprintf(stderr, _("Fatal error: %s\n"), s_szBuf); -#endif + wxSafeShowMessage(_T("Fatal Error"), s_szBuf); abort(); } @@ -246,7 +251,7 @@ void wxLogVerbose(const wxChar *szFormat, ...) p += 2; wxVsnprintf(p, len, szFormat, argptr); - + wxLog::OnLog(wxLOG_Trace, s_szBuf, time(NULL)); } } @@ -349,7 +354,7 @@ wxLog::wxLog() m_bHasMessages = FALSE; } -wxChar *wxLog::SetLogBuffer( wxChar *buf, size_t size = 0 ) +wxChar *wxLog::SetLogBuffer( wxChar *buf, size_t size) { wxChar *oldbuf = s_szBuf; @@ -561,7 +566,7 @@ Boolean IsCompatibleVersion(short inVersion) result = (inVersion <= block->apiHiVersion); } - return result; + return result; } /* --------------------------------------------------------------------------- @@ -764,16 +769,24 @@ void wxLogStream::DoLogString(const wxChar *szString, time_t WXUNUSED(t)) wxLogChain::wxLogChain(wxLog *logger) { + m_bPassMessages = TRUE; + m_logNew = logger; m_logOld = wxLog::SetActiveTarget(this); } -void wxLogChain::SetLog(wxLog *logger) +wxLogChain::~wxLogChain() { + delete m_logOld; + if ( m_logNew != this ) delete m_logNew; +} - wxLog::SetActiveTarget(logger); +void wxLogChain::SetLog(wxLog *logger) +{ + if ( m_logNew != this ) + delete m_logNew; m_logNew = logger; }