X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b46b1d59d6f69ad80dcf5955375578a6504d100a..85284ca4b226d9a1ab6bed26c5eaa480543649d5:/src/mgl/evtloop.cpp

diff --git a/src/mgl/evtloop.cpp b/src/mgl/evtloop.cpp
index ff5d985cce..452dbb4e0c 100644
--- a/src/mgl/evtloop.cpp
+++ b/src/mgl/evtloop.cpp
@@ -184,3 +184,39 @@ bool wxGUIEventLoop::Dispatch()
     return m_impl->GetKeepLooping();
 }
 
+
+//-----------------------------------------------------------------------------
+// wxYield
+//-----------------------------------------------------------------------------
+
+bool wxGUIEventLoop::YieldFor(long eventsToProcess)
+{
+#if wxUSE_THREADS
+    if ( !wxThread::IsMain() )
+    {
+        // can't process events from other threads, MGL is thread-unsafe
+        return true;
+    }
+#endif // wxUSE_THREADS
+
+    m_isInsideYield = true;
+    m_eventsToProcessInsideYield = eventsToProcess;
+
+    wxLog::Suspend();
+
+    // TODO: implement event filtering using the eventsToProcess mask
+
+    while (Pending())
+        Dispatch();
+
+    /* it's necessary to call ProcessIdle() to update the frames sizes which
+       might have been changed (it also will update other things set from
+       OnUpdateUI() which is a nice (and desired) side effect) */
+    while (wxTheApp->ProcessIdle()) { }
+
+    wxLog::Resume();
+
+    m_isInsideYield = false;
+
+    return true;
+}