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.
This commit is contained in:
Vadim Zeitlin 2024-01-31 04:08:26 +01:00
parent cfb321b175
commit a01c870dbb

View file

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