]> git.saurik.com Git - wxWidgets.git/commitdiff
an alternative fix which should replace patch 781918
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 14 Aug 2003 22:57:25 +0000 (22:57 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 14 Aug 2003 22:57:25 +0000 (22:57 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22900 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/thread.cpp

index 7c66077a993ce05dd6494a49104fe164931775b1..820f64cca9c3f957bb26376405666283c238c69a 100644 (file)
@@ -760,7 +760,7 @@ wxThreadInternal::WaitForTerminate(bool shouldCancel,
     if ( shouldResume )
         Resume();
 
-    // does is still run?
+    // is it still running?
     if ( isRunning || m_state == STATE_RUNNING )
     {
         if ( wxThread::IsMain() )
@@ -874,6 +874,12 @@ wxThreadInternal::WaitForTerminate(bool shouldCancel,
     if ( pRc )
         *pRc = rc;
 
+    // we don't need the thread handle any more
+    Free();
+
+    wxCriticalSectionLocker lock(critsect);
+    SetState(STATE_EXITED);
+
     return rc == (wxThread::ExitCode)-1 ? wxTHREAD_MISC_ERROR
                                         : wxTHREAD_NO_ERROR;
 }
@@ -937,10 +943,6 @@ bool wxThread::IsMain()
     return ::GetCurrentThreadId() == gs_idMainThread;
 }
 
-#ifdef Yield
-#undef Yield
-#endif
-
 void wxThread::Yield()
 {
     // 0 argument to Sleep() is special and means to just give away the rest of
@@ -1135,30 +1137,12 @@ wxThread::ExitCode wxThread::Wait()
 
     (void)m_internal->WaitForTerminate(false, m_critsect, &rc);
 
-    m_internal->Free();
-
-    wxCriticalSectionLocker lock(m_critsect);
-    m_internal->SetState(STATE_EXITED);
-
     return rc;
 }
 
 wxThreadError wxThread::Delete(ExitCode *pRc)
 {
-    wxThreadError rc = m_internal->WaitForTerminate(true, m_critsect, pRc);
-
-    if ( IsDetached() )
-    {
-        delete this;
-    }
-    else // joinable
-    {
-        // update the status of the joinable thread
-        wxCriticalSectionLocker lock(m_critsect);
-        m_internal->SetState(STATE_EXITED);
-    }
-
-    return rc;
+    return m_internal->WaitForTerminate(true, m_critsect, pRc);
 }
 
 wxThreadError wxThread::Kill()