From 35f1525fe96c9fc2ad3687aafb9e6272fe9830d7 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.9 6.8 6.5 Change-Id: I731ed8f53dffee33dcff73851876944c55a4ce6c Reviewed-by: Sami Shalayel (cherry picked from commit 99c7c1f4dadd96ff60ac2a614400def2ee1b78b7) Reviewed-by: Qt Cherry-pick Bot --- 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 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(nullptr); } QCoreApplication::postEvent(d, new WorkerRemoveEvent(id)); -- cgit v1.2.3