aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlworkerscript/qquickworkerscript.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2025-06-12 15:53:51 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2025-06-15 22:47:26 +0000
commit8aa598404c237502b697b91ac592933cd581b760 (patch)
treee2634311e11809bb7ef126826c4d79fef43eb9b4 /src/qmlworkerscript/qquickworkerscript.cpp
parent7b829951962a17dce8fbfed35f2e48546c30ae27 (diff)
WorkerScript: Properly reset entry in workers map on removal
If we leave the QQuickWorkerScript pointer around, we can process another message on the worker thread afterwards which would still create the worker script engine for the now-dead QQuickWorkerScript. This crashes. Pick-to: 6.8 6.5 Change-Id: I731ed8f53dffee33dcff73851876944c55a4ce6c Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> (cherry picked from commit 99c7c1f4dadd96ff60ac2a614400def2ee1b78b7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 35f1525fe96c9fc2ad3687aafb9e6272fe9830d7)
Diffstat (limited to 'src/qmlworkerscript/qquickworkerscript.cpp')
-rw-r--r--src/qmlworkerscript/qquickworkerscript.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/qmlworkerscript/qquickworkerscript.cpp b/src/qmlworkerscript/qquickworkerscript.cpp
index f8e732c665..1f1df4ad78 100644
--- a/src/qmlworkerscript/qquickworkerscript.cpp
+++ b/src/qmlworkerscript/qquickworkerscript.cpp
@@ -414,12 +414,14 @@ void QQuickWorkerScriptEngine::removeWorkerScript(int id)
{
{
QMutexLocker locker(&d->m_lock);
- const auto it = d->workers.constFind(id);
- if (it == d->workers.cend())
+ const auto it = d->workers.find(id);
+ if (it == d->workers.end())
return;
if (it->isT1())
workerScriptExtension(it->asT1())->owner = nullptr;
+ else
+ *it = static_cast<QQuickWorkerScript *>(nullptr);
}
QCoreApplication::postEvent(d, new WorkerRemoveEvent(id));