summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorten Sørvig <morten.sorvig@qt.io>2023-09-05 10:26:56 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-09-11 10:54:06 +0000
commit4c562f94c043d6b0594a61ffeae4368e05e29df4 (patch)
tree5d7f367d8b912e4bb51f9189a12003e10fa88c47
parent8bc45bcfc714b2fda2163f150c7c5d4601126685 (diff)
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>
-rw-r--r--src/corelib/kernel/qeventdispatcher_wasm.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/corelib/kernel/qeventdispatcher_wasm.cpp b/src/corelib/kernel/qeventdispatcher_wasm.cpp
index 482e617ba1..dac02ad24d 100644
--- a/src/corelib/kernel/qeventdispatcher_wasm.cpp
+++ b/src/corelib/kernel/qeventdispatcher_wasm.cpp
@@ -221,6 +221,11 @@ bool QEventDispatcherWasm::processEvents(QEventLoop::ProcessEventsFlags flags)
QCoreApplication::sendPostedEvents();
processWindowSystemEvents(flags);
+ // 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;