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
Change-Id: Ic4d91298986847e6095ce9daea51a4b974106c06
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
(cherry picked from commit fefb1e18b1b6834ea344bed273735f096c61eb90)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Morten Sørvig 2023-09-05 10:26:56 +02:00 committed by Qt Cherry-pick Bot
parent 43cfa11b31
commit 7549f7fdb0

View File

@ -225,6 +225,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;