]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/thread.cpp
Added dummy OnIdle to wxWindow in wxGTK; doc tweaks
[wxWidgets.git] / src / msw / thread.cpp
index 1e642fd8e81fb851421275c360b51a441bee85e8..3ee7c1149a9843ad07efe9f1f23f218a3f4463b6 100644 (file)
@@ -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;
 }
 
 // ----------------------------------------------------------------------------