add a critical section protecting ms_prev variables (replaces patch 1819224)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@49405 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -280,9 +280,14 @@ void WXDLLEXPORT wxLogSysError(long lErrCode, const wxChar *szFormat, ...)
|
||||
// wxLog class implementation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// define a critical section gs_prevCS protecting access to wxLog::ms_prevXXX
|
||||
wxCRIT_SECT_DECLARE(gs_prevCS);
|
||||
|
||||
/* static */
|
||||
unsigned wxLog::DoLogNumberOfRepeats()
|
||||
{
|
||||
wxCRIT_SECT_LOCKER(lock, gs_prevCS);
|
||||
|
||||
long retval = ms_prevCounter;
|
||||
wxLog *pLogger = GetActiveTarget();
|
||||
if ( pLogger && ms_prevCounter > 0 )
|
||||
@@ -305,12 +310,7 @@ unsigned wxLog::DoLogNumberOfRepeats()
|
||||
|
||||
wxLog::~wxLog()
|
||||
{
|
||||
if ( ms_prevCounter > 0 )
|
||||
{
|
||||
// looks like the repeat count has not been logged yet,
|
||||
// so let's do it now
|
||||
wxLog::DoLogNumberOfRepeats();
|
||||
}
|
||||
wxLog::DoLogNumberOfRepeats();
|
||||
}
|
||||
|
||||
/* static */
|
||||
@@ -321,21 +321,28 @@ void wxLog::OnLog(wxLogLevel level, const wxChar *szString, time_t t)
|
||||
wxLog *pLogger = GetActiveTarget();
|
||||
if ( pLogger )
|
||||
{
|
||||
if ( GetRepetitionCounting() && ms_prevString == szString )
|
||||
if ( GetRepetitionCounting() )
|
||||
{
|
||||
ms_prevCounter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( GetRepetitionCounting() )
|
||||
wxCRIT_SECT_LOCKER(lock, gs_prevCS);
|
||||
|
||||
if ( szString == ms_prevString )
|
||||
{
|
||||
DoLogNumberOfRepeats();
|
||||
ms_prevCounter++;
|
||||
|
||||
// nothing else to do, in particular, don't log the
|
||||
// repeated message
|
||||
return;
|
||||
}
|
||||
|
||||
DoLogNumberOfRepeats();
|
||||
|
||||
// reset repetition counter for a new message
|
||||
ms_prevString = szString;
|
||||
ms_prevLevel = level;
|
||||
ms_prevTimeStamp = t;
|
||||
pLogger->DoLog(level, szString, t);
|
||||
}
|
||||
|
||||
pLogger->DoLog(level, szString, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user