From 99c7c1f4dadd96ff60ac2a614400def2ee1b78b7 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 12 Jun 2025 15:53:51 +0200 Subject: 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.10 6.9 6.8 6.5 Change-Id: I731ed8f53dffee33dcff73851876944c55a4ce6c Reviewed-by: Sami Shalayel --- src/qmlworkerscript/qquickworkerscript.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/qmlworkerscript/qquickworkerscript.cpp') diff --git a/src/qmlworkerscript/qquickworkerscript.cpp b/src/qmlworkerscript/qquickworkerscript.cpp index d7c9f0192f..dbb8281a99 100644 --- a/src/qmlworkerscript/qquickworkerscript.cpp +++ b/src/qmlworkerscript/qquickworkerscript.cpp @@ -373,12 +373,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(nullptr); } QCoreApplication::postEvent(d, new WorkerRemoveEvent(id)); -- cgit v1.2.3