]> git.saurik.com Git - wxWidgets.git/blobdiff - src/unix/threadpsx.cpp
Correct initial value of "Toggle toolbar" check menu item in the sample.
[wxWidgets.git] / src / unix / threadpsx.cpp
index 700fd19324c2ab5dc83accc6c38be86657c84666..142268d1b069b98cb26d1c989c9ec5e94ef99006 100644 (file)
@@ -1778,14 +1778,15 @@ static void ScheduleThreadForDeletion()
 
 static void DeleteThread(wxThread *This)
 {
-    // gs_mutexDeleteThread should be unlocked before signalling the condition
-    // or wxThreadModule::OnExit() would deadlock
-    wxMutexLocker locker( *gs_mutexDeleteThread );
-
     wxLogTrace(TRACE_THREADS, wxT("Thread %p auto deletes."), This->GetId());
 
     delete This;
 
+    // only lock gs_mutexDeleteThread after deleting the thread to avoid
+    // calling out into user code with it locked as this may result in
+    // deadlocks if the thread dtor deletes another thread (see #11501)
+    wxMutexLocker locker( *gs_mutexDeleteThread );
+
     wxCHECK_RET( gs_nThreadsBeingDeleted > 0,
                  wxT("no threads scheduled for deletion, yet we delete one?") );