]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/evtloopcmn.cpp
Don't block in wxEventLoopManual::Dispatch() if loop was exited.
[wxWidgets.git] / src / common / evtloopcmn.cpp
index d824c3182240f579acb92d24107458fe753046f9..de9fce7230d2728d7fcbec491b95bdc6954efb4b 100644 (file)
@@ -104,8 +104,24 @@ bool wxEventLoopManual::ProcessEvents()
     // and this input is only removed from it when pending event handlers are
     // executed)
     if ( wxTheApp )
+    {
         wxTheApp->ProcessPendingEvents();
 
+        // One of the pending event handlers could have decided to exit the
+        // loop so check for the flag before trying to dispatch more events
+        // (which could block indefinitely if no more are coming).
+        if ( m_shouldExit )
+        {
+            // We still need to dispatch any remaining pending events, just as
+            // we do in the event loop in Run() if the loop is exited from a
+            // normal event handler.
+            while ( wxTheApp->HasPendingEvents() )
+                wxTheApp->ProcessPendingEvents();
+
+            return false;
+        }
+    }
+
     return Dispatch();
 }