summaryrefslogtreecommitdiff
blob: c58f3956d45388533097a9146eb077ca658f73c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
--- wxWidgets/src/gtk/app.cpp	2008/03/13 02:56:21	52464
+++ wxWidgets/src/gtk/app.cpp	2008/03/13 04:37:03	52465
@@ -174,59 +174,63 @@
     if (!wxTheApp)
         return false;
 
-    bool moreIdles = false;
-
+    guint idleID_save;
+    {
+        // Allow another idle source to be added while this one is busy.
+        // Needed if an idle event handler runs a new event loop,
+        // for example by showing a dialog.
+#if wxUSE_THREADS
+        wxMutexLocker lock(gs_idleTagsMutex);
+#endif
+        idleID_save = wxTheApp->m_idleTag;
+        wxTheApp->m_idleTag = 0;
+        g_isIdle = true;
+        wxAddEmissionHook();
+    }
 #ifdef __WXDEBUG__
     // don't generate the idle events while the assert modal dialog is shown,
     // this matches the behavior of wxMSW
-    if (!wxTheApp->IsInAssert())
+    if (wxTheApp->IsInAssert())
+        return false;
 #endif // __WXDEBUG__
-    {
-        guint idleID_save;
-        {
-            // Allow another idle source to be added while this one is busy.
-            // Needed if an idle event handler runs a new event loop,
-            // for example by showing a dialog.
-#if wxUSE_THREADS
-            wxMutexLocker lock(gs_idleTagsMutex);
-#endif
-            idleID_save = wxTheApp->m_idleTag;
-            wxTheApp->m_idleTag = 0;
-            g_isIdle = true;
-            wxAddEmissionHook();
-        }
 
-        // When getting called from GDK's time-out handler
-        // we are no longer within GDK's grab on the GUI
-        // thread so we must lock it here ourselves.
-        gdk_threads_enter();
-
-        // Send idle event to all who request them as long as
-        // no events have popped up in the event queue.
-        do {
-            moreIdles = wxTheApp->ProcessIdle();
-        } while (moreIdles && gtk_events_pending() == 0);
+    // When getting called from GDK's time-out handler
+    // we are no longer within GDK's grab on the GUI
+    // thread so we must lock it here ourselves.
+    gdk_threads_enter();
 
-        // Release lock again
-        gdk_threads_leave();
-        
-        {
-            // If another idle source was added, remove it
+    // Send idle event to all who request them as long as
+    // no events have popped up in the event queue.
+    bool moreIdles;
+    do {
+        moreIdles = wxTheApp->ProcessIdle();
+    } while (moreIdles && gtk_events_pending() == 0);
+
+    // Release lock again
+    gdk_threads_leave();
+    
 #if wxUSE_THREADS
-            wxMutexLocker lock(gs_idleTagsMutex);
+    wxMutexLocker lock(gs_idleTagsMutex);
 #endif
-            if (wxTheApp->m_idleTag != 0)
-                g_source_remove(wxTheApp->m_idleTag);
-            wxTheApp->m_idleTag = idleID_save;
-            g_isIdle = false;
-        }
-    }
+    // If another idle source was added, remove it
+    if (wxTheApp->m_idleTag != 0)
+        g_source_remove(wxTheApp->m_idleTag);
+    wxTheApp->m_idleTag = idleID_save;
+    g_isIdle = false;
 
-    if (!moreIdles)
-    {
 #if wxUSE_THREADS
-        wxMutexLocker lock(gs_idleTagsMutex);
+    if (wxPendingEventsLocker)
+        wxPendingEventsLocker->Enter();
 #endif
+    // Pending events can be added asynchronously,
+    // need to keep idle source if any have appeared
+    moreIdles = moreIdles || (wxPendingEvents && !wxPendingEvents->IsEmpty());
+#if wxUSE_THREADS
+    if (wxPendingEventsLocker)
+        wxPendingEventsLocker->Leave();
+#endif
+    if (!moreIdles)
+    {
         // Indicate that we are now in idle mode and event handlers
         // will have to reinstall the idle handler again.
         g_isIdle = true;