add a critical section protecting ms_prev variables (replaces patch 1819224)
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 24 Oct 2007 17:59:53 +0000 (17:59 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 24 Oct 2007 17:59:53 +0000 (17:59 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49404 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/log.h
src/common/log.cpp

index adab3ceb5baa5169a231eaa8b3af890b107faa0a..bff6f448c3d667a20b5cd2533010e2dc48f18eb2 100644 (file)
@@ -14,6 +14,8 @@
 
 #include "wx/defs.h"
 
+#include "wx/thread.h"
+
 // ----------------------------------------------------------------------------
 // common constants for use in wxUSE_LOG/!wxUSE_LOG
 // ----------------------------------------------------------------------------
@@ -313,6 +315,7 @@ private:
     // with the number of times it was repeated
     static bool        ms_bRepetCounting;
 
+    wxCRIT_SECT_DECLARE(ms_prevCS);     // protects the ms_prev values below
     static wxString    ms_prevString;   // previous message that was logged
     static unsigned    ms_prevCounter;  // how many times it was repeated
     static time_t      ms_prevTimeStamp;// timestamp of the previous message
index 03d6f0adf4ab98289f3ca2948c23e09d1c5ba498..9ca1c34bd7332d777acaef2053d46f5a2f9908ff 100644 (file)
@@ -460,6 +460,8 @@ void WXDLLEXPORT wxVLogSysError(unsigned long err, const wxString& format, va_li
 /* static */
 void wxLog::LogLastRepetitionCountIfNeeded()
 {
+    wxCRIT_SECT_LOCKER(lock, ms_prevCS);
+
     wxLog *pLogger = GetActiveTarget();
     if ( pLogger && ms_prevCounter )
     {
@@ -494,6 +496,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++;