From a01c870dbb24407575337ea0477374dec909e531 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 31 Jan 2024 04:08:26 +0100 Subject: [PATCH] Don't let exceptions escape from events handled during idle time This resulted in immediate program termination, at least with wxGTK, if an event handler called when dispatching pending events during idle time threw an exception (which, in particular, covers all the exceptions inside lambdas passed to CallAfter()). Just catch and handle them as usual, i.e. as we do with the event handlers called immediately in response to a user action. --- src/common/event.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common/event.cpp b/src/common/event.cpp index 0ad7eaaa4d..cba9fb1a44 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -1405,7 +1405,10 @@ void wxEvtHandler::ProcessPendingEvents() wxLEAVE_CRIT_SECT( m_pendingEventsLock ); - ProcessEvent(*event); + // We must not let exceptions escape from here, there is no outer exception + // handler to catch them and so letting them do it would just terminate the + // program. + SafelyProcessEvent(*event); // careful: this object could have been deleted by the event handler // executed by the above ProcessEvent() call, so we can't access any fields