diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-08-16 15:02:40 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-08-16 21:36:41 +0200 |
commit | a068fdc0b2cf7d4223d9ad15345fe9d345875936 (patch) | |
tree | d641853a9483489d2393c6c0b46e85e99257bdb1 /src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp | |
parent | 4ec8c0700cd0e6bc1b2dfb08fff5e9e15288e047 (diff) |
QmlPreview: Protect QQmlPreviewFileLoader::load with another mutex
We can concurrently load multiple files from different threads, but the
loader can only handle one such request at a time.
Fixes: QTBUG-95825
Pick-to: 6.2
Change-Id: I2b94d55f2cf0da6e84dabc47df5699cc57b903a6
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Knud Dollereder <knud.dollereder@qt.io>
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp | 8 |
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: |