X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8c10faf1bdfc5b827c4361216cfd39e3bbf027a4..20e85460c40ebc4dcc9577928771adb264cc998f:/src/msw/thread.cpp diff --git a/src/msw/thread.cpp b/src/msw/thread.cpp index 1e642fd8e8..3ee7c1149a 100644 --- a/src/msw/thread.cpp +++ b/src/msw/thread.cpp @@ -257,22 +257,29 @@ private: wxCriticalSection::wxCriticalSection() { - m_critsect = new wxCriticalSectionInternal; + m_critsect = NULL; } wxCriticalSection::~wxCriticalSection() { - delete m_critsect; + wxASSERT_MSG( !m_critsect, "Forgot to Leave() critical section" ); } void wxCriticalSection::Enter() { + m_critsect = new wxCriticalSectionInternal; + ::EnterCriticalSection(*m_critsect); } void wxCriticalSection::Leave() { + wxCHECK_RET( m_critsect, "Leave() without matching Enter()" ); + ::LeaveCriticalSection(*m_critsect); + + delete m_critsect; + m_critsect = NULL; } // ----------------------------------------------------------------------------