From 2d32b8cdd86b4d557340cdde49163226dc9d99c8 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Tue, 21 Mar 2023 11:08:09 -0700 Subject: [PATCH] Fix GSource leak from idle processing It is apparently not safe to call gtk_events_pending() from the idle callback, as it can result in GLib failing to properly dereference some GSource objects. This leads to increasingly large amounts of CPU time being spent in GLib processing internal lists of these GSource objects. So avoid calling gtk_events_pending(), as it is not strictly necessary because our idle source will remain installed if wxIdleEvent::RequestMore() is used, and if no events have arrived the idle callback will be invoked again. Closes #23364. See #23368. --- src/gtk/app.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 1d19fbce0e..c350e6ca17 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -142,12 +142,9 @@ bool wxApp::DoIdle() gs_focusChange = 0; } - bool needMore; - do { - ProcessPendingEvents(); + ProcessPendingEvents(); + const bool needMore = ProcessIdle(); - needMore = ProcessIdle(); - } while (needMore && gtk_events_pending() == 0); gdk_threads_leave(); #if wxUSE_THREADS