diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2025-06-12 15:53:51 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2025-06-14 09:22:54 +0200 |
| commit | 99c7c1f4dadd96ff60ac2a614400def2ee1b78b7 (patch) | |
| tree | 707adf7aef07a0d66ad745d8247bb3eb76a872ca /src/qmlworkerscript/qquickworkerscript.cpp | |
| parent | 9f1f147789acb299913de39dca0133a156e96249 (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.10 6.9 6.8 6.5
Change-Id: I731ed8f53dffee33dcff73851876944c55a4ce6c
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'src/qmlworkerscript/qquickworkerscript.cpp')
| -rw-r--r-- | src/qmlworkerscript/qquickworkerscript.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
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<QQuickWorkerScript *>(nullptr); } QCoreApplication::postEvent(d, new WorkerRemoveEvent(id)); |
