summaryrefslogtreecommitdiff
path: root/src/plugins/python/pythonutils.cpp
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2021-06-15 14:23:15 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2021-06-16 11:41:58 +0000
commitd4c36f43b0bdf7594bf3ce8652a9250623f41dee (patch)
tree38839d543239343fc0548241021dde1c0cb29b0e /src/plugins/python/pythonutils.cpp
parent905f5d4e1b5784001138f2acbbad0ed9c49aa714 (diff)
downloadqt-creator-d4c36f43b0bdf7594bf3ce8652a9250623f41dee.tar.gz
Protect the access to module path for executable cache
The getPylsModulePath() may be called concurrently: PyLSConfigureAssistant::openDocumentWithPython() -> runAsync -> checkPythonLanguageServer() -> getPylsModulePath(), so protect the access to the static cache by mutex. Amends: 54f2ebf91d76d05d0202de5263939fc4ba227fed Change-Id: Ia88a9e680b092bcc7cf62338387775521d497835 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/python/pythonutils.cpp')
-rw-r--r--src/plugins/python/pythonutils.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp
index af1c42b5ab..f679fe2b0f 100644
--- a/src/plugins/python/pythonutils.cpp
+++ b/src/plugins/python/pythonutils.cpp
@@ -98,6 +98,8 @@ static QString pythonName(const FilePath &pythonPath)
FilePath getPylsModulePath(CommandLine pylsCommand)
{
+ static QMutex mutex; // protect the access to the cache
+ QMutexLocker locker(&mutex);
static QMap<FilePath, FilePath> cache;
const FilePath &modulePath = cache.value(pylsCommand.executable());
if (!modulePath.isEmpty())