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 18:51:56 +0000
commit35f1525fe96c9fc2ad3687aafb9e6272fe9830d7 (patch)
treecfa0e5463f383147c95faa95dadeed49c4019474 /src/qmlworkerscript/qquickworkerscript.cpp
parentfa84c5d23054090e000dc0122cc94444124914a4 (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.9 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>
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 750a2ab805..3235fd410d 100644
--- a/src/qmlworkerscript/qquickworkerscript.cpp
+++ b/src/qmlworkerscript/qquickworkerscript.cpp
@@ -411,12 +411,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));