]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed deadlock when calling wxPostEvent() from worker thread
authorVáclav Slavík <vslavik@fastmail.fm>
Wed, 3 Jan 2007 17:25:47 +0000 (17:25 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Wed, 3 Jan 2007 17:25:47 +0000 (17:25 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44092 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/dfb/evtloop.cpp

index 2ecc94a9b4212a7fd3fd0792349df235cdc6e6d7..3cc18ac29091a7979c572b1730813172744f1d76 100644 (file)
@@ -25,6 +25,7 @@
     #include "wx/app.h"
 #endif
 
+#include "wx/thread.h"
 #include "wx/timer.h"
 #include "wx/private/socketevtdispatch.h"
 #include "wx/dfb/private.h"
@@ -88,7 +89,16 @@ bool wxEventLoop::Dispatch()
     //     OnNextIteration() will be called frequently enough
     const int TIMEOUT = 100;
 
-    if ( ms_buffer->WaitForEventWithTimeout(0, TIMEOUT) )
+    // release the GUI mutex so that other threads have a chance to post
+    // events:
+    wxMutexGuiLeave();
+
+    bool rv = ms_buffer->WaitForEventWithTimeout(0, TIMEOUT);
+
+    // and acquire it back before calling any event handlers:
+    wxMutexGuiEnter();
+
+    if ( rv )
     {
         switch ( ms_buffer->GetLastResult() )
         {