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
|
// wxLog class implementation
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// define a critical section gs_prevCS protecting access to wxLog::ms_prevXXX
|
||||||
|
wxCRIT_SECT_DECLARE(gs_prevCS);
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
unsigned wxLog::DoLogNumberOfRepeats()
|
unsigned wxLog::DoLogNumberOfRepeats()
|
||||||
{
|
{
|
||||||
|
wxCRIT_SECT_LOCKER(lock, gs_prevCS);
|
||||||
|
|
||||||
long retval = ms_prevCounter;
|
long retval = ms_prevCounter;
|
||||||
wxLog *pLogger = GetActiveTarget();
|
wxLog *pLogger = GetActiveTarget();
|
||||||
if ( pLogger && ms_prevCounter > 0 )
|
if ( pLogger && ms_prevCounter > 0 )
|
||||||
@@ -305,12 +310,7 @@ unsigned wxLog::DoLogNumberOfRepeats()
|
|||||||
|
|
||||||
wxLog::~wxLog()
|
wxLog::~wxLog()
|
||||||
{
|
{
|
||||||
if ( ms_prevCounter > 0 )
|
wxLog::DoLogNumberOfRepeats();
|
||||||
{
|
|
||||||
// looks like the repeat count has not been logged yet,
|
|
||||||
// so let's do it now
|
|
||||||
wxLog::DoLogNumberOfRepeats();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
@@ -321,21 +321,28 @@ void wxLog::OnLog(wxLogLevel level, const wxChar *szString, time_t t)
|
|||||||
wxLog *pLogger = GetActiveTarget();
|
wxLog *pLogger = GetActiveTarget();
|
||||||
if ( pLogger )
|
if ( pLogger )
|
||||||
{
|
{
|
||||||
if ( GetRepetitionCounting() && ms_prevString == szString )
|
if ( GetRepetitionCounting() )
|
||||||
{
|
{
|
||||||
ms_prevCounter++;
|
wxCRIT_SECT_LOCKER(lock, gs_prevCS);
|
||||||
}
|
|
||||||
else
|
if ( szString == ms_prevString )
|
||||||
{
|
|
||||||
if ( GetRepetitionCounting() )
|
|
||||||
{
|
{
|
||||||
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_prevString = szString;
|
||||||
ms_prevLevel = level;
|
ms_prevLevel = level;
|
||||||
ms_prevTimeStamp = t;
|
ms_prevTimeStamp = t;
|
||||||
pLogger->DoLog(level, szString, t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pLogger->DoLog(level, szString, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user