X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2064113c9d9f81acb851b974a21a5f9170dfe9e2..6403484578149a9ed8d40f38cb21d311b79a33ac:/src/common/log.cpp?ds=sidebyside diff --git a/src/common/log.cpp b/src/common/log.cpp index 03d6f0adf4..c2a69b6714 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -457,11 +457,13 @@ void WXDLLEXPORT wxVLogSysError(unsigned long err, const wxString& format, va_li // wxLog class implementation // ---------------------------------------------------------------------------- -/* static */ -void wxLog::LogLastRepetitionCountIfNeeded() +unsigned wxLog::LogLastRepetitionCountIfNeeded() { - wxLog *pLogger = GetActiveTarget(); - if ( pLogger && ms_prevCounter ) + wxCRIT_SECT_LOCKER(lock, ms_prevCS); + + const unsigned count = ms_prevCounter; + + if ( ms_prevCounter ) { wxString msg; #if wxUSE_INTL @@ -475,8 +477,10 @@ void wxLog::LogLastRepetitionCountIfNeeded() #endif ms_prevCounter = 0; ms_prevString.clear(); - pLogger->DoLog(ms_prevLevel, msg, ms_prevTimeStamp); + DoLog(ms_prevLevel, msg, ms_prevTimeStamp); } + + return count; } wxLog::~wxLog() @@ -494,6 +498,8 @@ void wxLog::OnLog(wxLogLevel level, const wxString& szString, time_t t) { if ( GetRepetitionCounting() ) { + wxCRIT_SECT_LOCKER(lock, ms_prevCS); + if ( szString == ms_prevString ) { ms_prevCounter++; @@ -503,7 +509,7 @@ void wxLog::OnLog(wxLogLevel level, const wxString& szString, time_t t) return; } - LogLastRepetitionCountIfNeeded(); + pLogger->LogLastRepetitionCountIfNeeded(); // reset repetition counter for a new message ms_prevString = szString; @@ -900,6 +906,9 @@ wxLogInterposerTemp::wxLogInterposerTemp() // static variables // ---------------------------------------------------------------------------- +#if wxUSE_THREADS +wxCriticalSection wxLog::ms_prevCS; +#endif // wxUSE_THREADS bool wxLog::ms_bRepetCounting = false; wxString wxLog::ms_prevString; unsigned int wxLog::ms_prevCounter = 0;