]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/log.cpp
wxChar -> char
[wxWidgets.git] / src / common / log.cpp
index 03d6f0adf4ab98289f3ca2948c23e09d1c5ba498..c2a69b67142604a141ed6fd285c880bfade31390 100644 (file)
@@ -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;