|
Dan Horák |
2c4c22 |
--- wxWidgets/src/gtk/app.cpp 2008/03/13 02:56:21 52464
|
|
Dan Horák |
2c4c22 |
+++ wxWidgets/src/gtk/app.cpp 2008/03/13 04:37:03 52465
|
|
Dan Horák |
2c4c22 |
@@ -174,59 +174,63 @@
|
|
Dan Horák |
2c4c22 |
if (!wxTheApp)
|
|
Dan Horák |
2c4c22 |
return false;
|
|
Dan Horák |
2c4c22 |
|
|
Dan Horák |
2c4c22 |
- bool moreIdles = false;
|
|
Dan Horák |
2c4c22 |
-
|
|
Dan Horák |
2c4c22 |
+ guint idleID_save;
|
|
Dan Horák |
2c4c22 |
+ {
|
|
Dan Horák |
2c4c22 |
+ // Allow another idle source to be added while this one is busy.
|
|
Dan Horák |
2c4c22 |
+ // Needed if an idle event handler runs a new event loop,
|
|
Dan Horák |
2c4c22 |
+ // for example by showing a dialog.
|
|
Dan Horák |
2c4c22 |
+#if wxUSE_THREADS
|
|
Dan Horák |
2c4c22 |
+ wxMutexLocker lock(gs_idleTagsMutex);
|
|
Dan Horák |
2c4c22 |
+#endif
|
|
Dan Horák |
2c4c22 |
+ idleID_save = wxTheApp->m_idleTag;
|
|
Dan Horák |
2c4c22 |
+ wxTheApp->m_idleTag = 0;
|
|
Dan Horák |
2c4c22 |
+ g_isIdle = true;
|
|
Dan Horák |
2c4c22 |
+ wxAddEmissionHook();
|
|
Dan Horák |
2c4c22 |
+ }
|
|
Dan Horák |
2c4c22 |
#ifdef __WXDEBUG__
|
|
Dan Horák |
2c4c22 |
// don't generate the idle events while the assert modal dialog is shown,
|
|
Dan Horák |
2c4c22 |
// this matches the behavior of wxMSW
|
|
Dan Horák |
2c4c22 |
- if (!wxTheApp->IsInAssert())
|
|
Dan Horák |
2c4c22 |
+ if (wxTheApp->IsInAssert())
|
|
Dan Horák |
2c4c22 |
+ return false;
|
|
Dan Horák |
2c4c22 |
#endif // __WXDEBUG__
|
|
Dan Horák |
2c4c22 |
- {
|
|
Dan Horák |
2c4c22 |
- guint idleID_save;
|
|
Dan Horák |
2c4c22 |
- {
|
|
Dan Horák |
2c4c22 |
- // Allow another idle source to be added while this one is busy.
|
|
Dan Horák |
2c4c22 |
- // Needed if an idle event handler runs a new event loop,
|
|
Dan Horák |
2c4c22 |
- // for example by showing a dialog.
|
|
Dan Horák |
2c4c22 |
-#if wxUSE_THREADS
|
|
Dan Horák |
2c4c22 |
- wxMutexLocker lock(gs_idleTagsMutex);
|
|
Dan Horák |
2c4c22 |
-#endif
|
|
Dan Horák |
2c4c22 |
- idleID_save = wxTheApp->m_idleTag;
|
|
Dan Horák |
2c4c22 |
- wxTheApp->m_idleTag = 0;
|
|
Dan Horák |
2c4c22 |
- g_isIdle = true;
|
|
Dan Horák |
2c4c22 |
- wxAddEmissionHook();
|
|
Dan Horák |
2c4c22 |
- }
|
|
Dan Horák |
2c4c22 |
|
|
Dan Horák |
2c4c22 |
- // When getting called from GDK's time-out handler
|
|
Dan Horák |
2c4c22 |
- // we are no longer within GDK's grab on the GUI
|
|
Dan Horák |
2c4c22 |
- // thread so we must lock it here ourselves.
|
|
Dan Horák |
2c4c22 |
- gdk_threads_enter();
|
|
Dan Horák |
2c4c22 |
-
|
|
Dan Horák |
2c4c22 |
- // Send idle event to all who request them as long as
|
|
Dan Horák |
2c4c22 |
- // no events have popped up in the event queue.
|
|
Dan Horák |
2c4c22 |
- do {
|
|
Dan Horák |
2c4c22 |
- moreIdles = wxTheApp->ProcessIdle();
|
|
Dan Horák |
2c4c22 |
- } while (moreIdles && gtk_events_pending() == 0);
|
|
Dan Horák |
2c4c22 |
+ // When getting called from GDK's time-out handler
|
|
Dan Horák |
2c4c22 |
+ // we are no longer within GDK's grab on the GUI
|
|
Dan Horák |
2c4c22 |
+ // thread so we must lock it here ourselves.
|
|
Dan Horák |
2c4c22 |
+ gdk_threads_enter();
|
|
Dan Horák |
2c4c22 |
|
|
Dan Horák |
2c4c22 |
- // Release lock again
|
|
Dan Horák |
2c4c22 |
- gdk_threads_leave();
|
|
Dan Horák |
2c4c22 |
-
|
|
Dan Horák |
2c4c22 |
- {
|
|
Dan Horák |
2c4c22 |
- // If another idle source was added, remove it
|
|
Dan Horák |
2c4c22 |
+ // Send idle event to all who request them as long as
|
|
Dan Horák |
2c4c22 |
+ // no events have popped up in the event queue.
|
|
Dan Horák |
2c4c22 |
+ bool moreIdles;
|
|
Dan Horák |
2c4c22 |
+ do {
|
|
Dan Horák |
2c4c22 |
+ moreIdles = wxTheApp->ProcessIdle();
|
|
Dan Horák |
2c4c22 |
+ } while (moreIdles && gtk_events_pending() == 0);
|
|
Dan Horák |
2c4c22 |
+
|
|
Dan Horák |
2c4c22 |
+ // Release lock again
|
|
Dan Horák |
2c4c22 |
+ gdk_threads_leave();
|
|
Dan Horák |
2c4c22 |
+
|
|
Dan Horák |
2c4c22 |
#if wxUSE_THREADS
|
|
Dan Horák |
2c4c22 |
- wxMutexLocker lock(gs_idleTagsMutex);
|
|
Dan Horák |
2c4c22 |
+ wxMutexLocker lock(gs_idleTagsMutex);
|
|
Dan Horák |
2c4c22 |
#endif
|
|
Dan Horák |
2c4c22 |
- if (wxTheApp->m_idleTag != 0)
|
|
Dan Horák |
2c4c22 |
- g_source_remove(wxTheApp->m_idleTag);
|
|
Dan Horák |
2c4c22 |
- wxTheApp->m_idleTag = idleID_save;
|
|
Dan Horák |
2c4c22 |
- g_isIdle = false;
|
|
Dan Horák |
2c4c22 |
- }
|
|
Dan Horák |
2c4c22 |
- }
|
|
Dan Horák |
2c4c22 |
+ // If another idle source was added, remove it
|
|
Dan Horák |
2c4c22 |
+ if (wxTheApp->m_idleTag != 0)
|
|
Dan Horák |
2c4c22 |
+ g_source_remove(wxTheApp->m_idleTag);
|
|
Dan Horák |
2c4c22 |
+ wxTheApp->m_idleTag = idleID_save;
|
|
Dan Horák |
2c4c22 |
+ g_isIdle = false;
|
|
Dan Horák |
2c4c22 |
|
|
Dan Horák |
2c4c22 |
- if (!moreIdles)
|
|
Dan Horák |
2c4c22 |
- {
|
|
Dan Horák |
2c4c22 |
#if wxUSE_THREADS
|
|
Dan Horák |
2c4c22 |
- wxMutexLocker lock(gs_idleTagsMutex);
|
|
Dan Horák |
2c4c22 |
+ if (wxPendingEventsLocker)
|
|
Dan Horák |
2c4c22 |
+ wxPendingEventsLocker->Enter();
|
|
Dan Horák |
2c4c22 |
#endif
|
|
Dan Horák |
2c4c22 |
+ // Pending events can be added asynchronously,
|
|
Dan Horák |
2c4c22 |
+ // need to keep idle source if any have appeared
|
|
Dan Horák |
2c4c22 |
+ moreIdles = moreIdles || (wxPendingEvents && !wxPendingEvents->IsEmpty());
|
|
Dan Horák |
2c4c22 |
+#if wxUSE_THREADS
|
|
Dan Horák |
2c4c22 |
+ if (wxPendingEventsLocker)
|
|
Dan Horák |
2c4c22 |
+ wxPendingEventsLocker->Leave();
|
|
Dan Horák |
2c4c22 |
+#endif
|
|
Dan Horák |
2c4c22 |
+ if (!moreIdles)
|
|
Dan Horák |
2c4c22 |
+ {
|
|
Dan Horák |
2c4c22 |
// Indicate that we are now in idle mode and event handlers
|
|
Dan Horák |
2c4c22 |
// will have to reinstall the idle handler again.
|
|
Dan Horák |
2c4c22 |
g_isIdle = true;
|
|
Dan Horák |
2c4c22 |
|