aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/types
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-08-20 15:29:05 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-08-21 06:33:42 +0000
commitcd3e2588e672a9ceea0c165a84bcd2ab89ab708f (patch)
treefc84d75ff59217e2b6c5dc3c8503be0d1749a4c3 /src/qml/types
parentec022d0efec47e0e68cdec1c2e018ce864cc015c (diff)
Fix race condition when removing worker scripts
As reported by TSAN, while registering new workers is done in the QML engine thread with the lock held, the removal of workers from the hash is done without a lock in the thread and therefore a data race. Change-Id: I932ed6127fe34b3b3da0b0202f42e877ae6e0d5f Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/types')
-rw-r--r--src/qml/types/qquickworkerscript.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp
index 4fef0fab7c..f8616bf709 100644
--- a/src/qml/types/qquickworkerscript.cpp
+++ b/src/qml/types/qquickworkerscript.cpp
@@ -215,6 +215,7 @@ bool QQuickWorkerScriptEnginePrivate::event(QEvent *event)
emit stopThread();
return true;
} else if (event->type() == (QEvent::Type)WorkerRemoveEvent::WorkerRemove) {
+ QMutexLocker locker(&m_lock);
WorkerRemoveEvent *workerEvent = static_cast<WorkerRemoveEvent *>(event);
QHash<int, WorkerScript *>::iterator itr = workers.find(workerEvent->workerId());
if (itr != workers.end()) {