aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2022-08-16 20:37:22 +0300
committerTarja Sundqvist <tarja.sundqvist@qt.io>2022-08-16 20:37:22 +0300
commitf274d775774b78f6217c9770ae87045d969acbe1 (patch)
treed14162d5a1badabc71f6034bd4013b521d8f52e9 /src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp
parentae66ecf0f95c79d730190b92e641c0410d5d6896 (diff)
parenteaf011c4ae440bbf7a02ceb7a33be5dfa5bcf907 (diff)
Merge remote-tracking branch 'origin/tqtc/lts-5.15.6' into tqtc/lts-5.15-opensourcev5.15.6-lts-lgpl
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp')
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp
index 5e78539155..e11b8c9776 100644
--- a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp
@@ -398,6 +398,14 @@ bool QQmlPreviewFileEngine::supportsExtension(Extension extension) const
void QQmlPreviewFileEngine::load() const
{
+ // We can get here from different threads on different instances of QQmlPreviewFileEngine.
+ // However, there is only one loader per QQmlPreviewFileEngineHandler and it is not thread-safe.
+ // Its content mutex doesn't help us here because we explicitly wait on it in load(), which
+ // causes it to be released. Therefore, lock the load mutex first.
+ // This doesn't cause any deadlocks because the only thread that wakes the loader on the content
+ // mutex never calls load(). It's the QML debug server thread that handles the debug protocol.
+ QMutexLocker loadLocker(m_loader->loadMutex());
+
m_result = m_loader->load(m_absolute);
switch (m_result) {
case QQmlPreviewFileLoader::File: