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.
This commit is contained in:
Paul Cornett 2023-03-21 11:08:09 -07:00 committed by Vadim Zeitlin
parent 23ccdb23c8
commit 2d32b8cdd8

View file

@ -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