+
+ // delete this mutex as late as possible as it's used from WakeUpIdle(), in
+ // particular do it after calling the base class CleanUp() which can result
+ // in it being called
+#if wxUSE_THREADS
+ delete m_idleMutex;
+ m_idleMutex = NULL;
+#endif
+}
+
+void wxApp::WakeUpIdle()
+{
+#if wxUSE_THREADS
+ wxMutexLocker lock(*m_idleMutex);
+#endif
+ if (m_idleSourceId == 0)
+ m_idleSourceId = g_idle_add_full(G_PRIORITY_LOW, wxapp_idle_callback, NULL, NULL);
+}
+
+// Checking for pending events requires first removing our idle source,
+// otherwise it will cause the check to always return true.
+bool wxApp::EventsPending()
+{
+#if wxUSE_THREADS
+ wxMutexLocker lock(*m_idleMutex);
+#endif
+ if (m_idleSourceId != 0)
+ {
+ g_source_remove(m_idleSourceId);
+ m_idleSourceId = 0;
+ wx_add_idle_hooks();
+ }
+ return gtk_events_pending() != 0;