wasm: don't crash if app is deleteLater()ed

We check for a valid event dispatcher when waking up,
but there was no check after processing queued events,
and processEvents() would continue with a stale this
pointer if one of the queued events happened to delete
the application object.

Fix this by checking if this is still a valid pointer
after processing events.

Fixes: QTBUG-116330
Pick-to: 6.6 6.5
Change-Id: Ic4d91298986847e6095ce9daea51a4b974106c06
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
bb10
Morten Sørvig 2023-09-05 10:26:56 +02:00 committed by Morten Johan Sørvig
parent 09e698d826
commit fefb1e18b1
1 changed files with 5 additions and 0 deletions

View File

@ -299,6 +299,11 @@ bool QEventDispatcherWasm::processEvents(QEventLoop::ProcessEventsFlags flags)
processPostedEvents();
// The processPostedEvents() call above may process an event which deletes the
// application object and the event dispatcher; stop event processing in that case.
if (!isValidEventDispatcherPointer(this))
return false;
if (m_interrupted) {
m_interrupted = false;
return false;