protect access to ms_aTraceMasks with a critical section (replaces patch 1911172)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52541 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -202,8 +202,7 @@ public:
|
|||||||
static void SetTraceMask(wxTraceMask ulMask) { ms_ulTraceMask = ulMask; }
|
static void SetTraceMask(wxTraceMask ulMask) { ms_ulTraceMask = ulMask; }
|
||||||
|
|
||||||
// add string trace mask
|
// add string trace mask
|
||||||
static void AddTraceMask(const wxString& str)
|
static void AddTraceMask(const wxString& str);
|
||||||
{ ms_aTraceMasks.push_back(str); }
|
|
||||||
|
|
||||||
// add string trace mask
|
// add string trace mask
|
||||||
static void RemoveTraceMask(const wxString& str);
|
static void RemoveTraceMask(const wxString& str);
|
||||||
@@ -211,7 +210,8 @@ public:
|
|||||||
// remove all string trace masks
|
// remove all string trace masks
|
||||||
static void ClearTraceMasks();
|
static void ClearTraceMasks();
|
||||||
|
|
||||||
// get string trace masks
|
// get string trace masks: note that this is MT-unsafe if other threads can
|
||||||
|
// call AddTraceMask() concurrently
|
||||||
static const wxArrayString& GetTraceMasks() { return ms_aTraceMasks; }
|
static const wxArrayString& GetTraceMasks() { return ms_aTraceMasks; }
|
||||||
|
|
||||||
// sets the time stamp string format: this is used as strftime() format
|
// sets the time stamp string format: this is used as strftime() format
|
||||||
@@ -345,6 +345,9 @@ private:
|
|||||||
// disabled
|
// disabled
|
||||||
static wxString ms_timestamp;
|
static wxString ms_timestamp;
|
||||||
|
|
||||||
|
#if wxUSE_THREADS
|
||||||
|
static wxCriticalSection ms_traceCS; // protects ms_aTraceMasks
|
||||||
|
#endif
|
||||||
static wxTraceMask ms_ulTraceMask; // controls wxLogTrace behaviour
|
static wxTraceMask ms_ulTraceMask; // controls wxLogTrace behaviour
|
||||||
static wxArrayString ms_aTraceMasks; // more powerful filter for wxLogTrace
|
static wxArrayString ms_aTraceMasks; // more powerful filter for wxLogTrace
|
||||||
};
|
};
|
||||||
|
@@ -618,8 +618,17 @@ void wxLog::DoCreateOnDemand()
|
|||||||
ms_bAutoCreate = true;
|
ms_bAutoCreate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxLog::AddTraceMask(const wxString& str)
|
||||||
|
{
|
||||||
|
wxCRIT_SECT_LOCKER(lock, ms_traceCS);
|
||||||
|
|
||||||
|
ms_aTraceMasks.push_back(str);
|
||||||
|
}
|
||||||
|
|
||||||
void wxLog::RemoveTraceMask(const wxString& str)
|
void wxLog::RemoveTraceMask(const wxString& str)
|
||||||
{
|
{
|
||||||
|
wxCRIT_SECT_LOCKER(lock, ms_traceCS);
|
||||||
|
|
||||||
int index = ms_aTraceMasks.Index(str);
|
int index = ms_aTraceMasks.Index(str);
|
||||||
if ( index != wxNOT_FOUND )
|
if ( index != wxNOT_FOUND )
|
||||||
ms_aTraceMasks.RemoveAt((size_t)index);
|
ms_aTraceMasks.RemoveAt((size_t)index);
|
||||||
@@ -627,6 +636,8 @@ void wxLog::RemoveTraceMask(const wxString& str)
|
|||||||
|
|
||||||
void wxLog::ClearTraceMasks()
|
void wxLog::ClearTraceMasks()
|
||||||
{
|
{
|
||||||
|
wxCRIT_SECT_LOCKER(lock, ms_traceCS);
|
||||||
|
|
||||||
ms_aTraceMasks.Clear();
|
ms_aTraceMasks.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -722,11 +733,16 @@ void wxLog::Flush()
|
|||||||
|
|
||||||
/*static*/ bool wxLog::IsAllowedTraceMask(const wxString& mask)
|
/*static*/ bool wxLog::IsAllowedTraceMask(const wxString& mask)
|
||||||
{
|
{
|
||||||
|
wxCRIT_SECT_LOCKER(lock, ms_traceCS);
|
||||||
|
|
||||||
for ( wxArrayString::iterator it = ms_aTraceMasks.begin(),
|
for ( wxArrayString::iterator it = ms_aTraceMasks.begin(),
|
||||||
en = ms_aTraceMasks.end();
|
en = ms_aTraceMasks.end();
|
||||||
it != en; ++it )
|
it != en; ++it )
|
||||||
|
{
|
||||||
if ( *it == mask)
|
if ( *it == mask)
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -924,7 +940,8 @@ wxLogInterposerTemp::wxLogInterposerTemp()
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
wxCriticalSection wxLog::ms_prevCS;
|
wxCriticalSection wxLog::ms_prevCS,
|
||||||
|
wxLog::ms_traceCS;
|
||||||
#endif // wxUSE_THREADS
|
#endif // wxUSE_THREADS
|
||||||
bool wxLog::ms_bRepetCounting = false;
|
bool wxLog::ms_bRepetCounting = false;
|
||||||
wxString wxLog::ms_prevString;
|
wxString wxLog::ms_prevString;
|
||||||
|
Reference in New Issue
Block a user