wxCriticalSection changes undone - should work now

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1842 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-03-01 18:20:12 +00:00
parent 7d532b0ceb
commit 26128999a7
2 changed files with 9 additions and 12 deletions

View File

@@ -1461,12 +1461,16 @@ void wxArrayString::Remove(const char *sz)
// need a critical section to protect access to gs_compareFunction and // need a critical section to protect access to gs_compareFunction and
// gs_sortAscending variables // gs_sortAscending variables
static wxCriticalSection gs_critsectStringSort; static wxCriticalSection *gs_critsectStringSort = NULL;
// call this before the value of the global sort vars is changed/after // call this before the value of the global sort vars is changed/after
// you're finished with them // you're finished with them
#define START_SORT() gs_critsectStringSort.Enter() #define START_SORT() wxASSERT( !gs_critsectStringSort ); \
#define END_SORT() gs_critsectStringSort.Leave() gs_critsectStringSort = new wxCriticalSection; \
gs_critsectStringSort->Enter()
#define END_SORT() gs_critsectStringSort->Leave(); \
delete gs_critsectStringSort; \
gs_critsectStringSort = NULL
#else // !threads #else // !threads
#define START_SORT() #define START_SORT()
#define END_SORT() #define END_SORT()

View File

@@ -257,29 +257,22 @@ private:
wxCriticalSection::wxCriticalSection() wxCriticalSection::wxCriticalSection()
{ {
m_critsect = NULL; m_critsect = new wxCriticalSectionInternal;
} }
wxCriticalSection::~wxCriticalSection() wxCriticalSection::~wxCriticalSection()
{ {
wxASSERT_MSG( !m_critsect, "Forgot to Leave() critical section" ); delete m_critsect;
} }
void wxCriticalSection::Enter() void wxCriticalSection::Enter()
{ {
m_critsect = new wxCriticalSectionInternal;
::EnterCriticalSection(*m_critsect); ::EnterCriticalSection(*m_critsect);
} }
void wxCriticalSection::Leave() void wxCriticalSection::Leave()
{ {
wxCHECK_RET( m_critsect, "Leave() without matching Enter()" );
::LeaveCriticalSection(*m_critsect); ::LeaveCriticalSection(*m_critsect);
delete m_critsect;
m_critsect = NULL;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------