forked from qt-creator/qt-creator
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: 54f2ebf91d
Change-Id: Ia88a9e680b092bcc7cf62338387775521d497835
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -98,6 +98,8 @@ static QString pythonName(const FilePath &pythonPath)
|
|||||||
|
|
||||||
FilePath getPylsModulePath(CommandLine pylsCommand)
|
FilePath getPylsModulePath(CommandLine pylsCommand)
|
||||||
{
|
{
|
||||||
|
static QMutex mutex; // protect the access to the cache
|
||||||
|
QMutexLocker locker(&mutex);
|
||||||
static QMap<FilePath, FilePath> cache;
|
static QMap<FilePath, FilePath> cache;
|
||||||
const FilePath &modulePath = cache.value(pylsCommand.executable());
|
const FilePath &modulePath = cache.value(pylsCommand.executable());
|
||||||
if (!modulePath.isEmpty())
|
if (!modulePath.isEmpty())
|
||||||
|
|||||||
Reference in New Issue
Block a user