summaryrefslogtreecommitdiff
path: root/src/plugins/python
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2019-11-04 14:41:36 +0100
committerEike Ziller <eike.ziller@qt.io>2019-11-04 14:41:36 +0100
commit04f0123c43ab602880da3fd41c9f650882ac39b6 (patch)
tree3c9d289b3d10285dc9e164cdf6a8232f656d7036 /src/plugins/python
parent03a52b9c8725992408f0087294ab1bc5be9159e6 (diff)
parent5ece12d4ea9291f1063b9c7ec71fb9764537cfdb (diff)
downloadqt-creator-04f0123c43ab602880da3fd41c9f650882ac39b6.tar.gz
Merge remote-tracking branch 'origin/4.11'
Change-Id: Ie951c531a5b2efd8e6b972c4d04b7f1c681c8ef9
Diffstat (limited to 'src/plugins/python')
-rw-r--r--src/plugins/python/pythonsettings.cpp2
-rw-r--r--src/plugins/python/pythonutils.cpp14
2 files changed, 12 insertions, 4 deletions
diff --git a/src/plugins/python/pythonsettings.cpp b/src/plugins/python/pythonsettings.cpp
index acb7a50ddd..ab5f024765 100644
--- a/src/plugins/python/pythonsettings.cpp
+++ b/src/plugins/python/pythonsettings.cpp
@@ -530,7 +530,7 @@ QList<Interpreter> PythonSettings::detectPythonVenvs(const FilePath &path)
void PythonSettings::saveSettings()
{
const QList<Interpreter> &interpreters = interpreterOptionsPage().interpreters();
- const QString &defaultId = interpreterOptionsPage().defaultInterpreter().id;
+ const QString defaultId = interpreterOptionsPage().defaultInterpreter().id;
toSettings(Core::ICore::settings(), {interpreters, defaultId});
if (QTC_GUARD(settingsInstance))
emit settingsInstance->interpretersChanged(interpreters, defaultId);
diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp
index aa7051b396..dced51518b 100644
--- a/src/plugins/python/pythonutils.cpp
+++ b/src/plugins/python/pythonutils.cpp
@@ -94,6 +94,11 @@ static QString pythonName(const FilePath &pythonPath)
FilePath getPylsModulePath(CommandLine pylsCommand)
{
+ static QMap<FilePath, FilePath> cache;
+ const FilePath &modulePath = cache.value(pylsCommand.executable());
+ if (!modulePath.isEmpty())
+ return modulePath;
+
pylsCommand.addArg("-h");
SynchronousProcess pythonProcess;
pythonProcess.setEnvironment(pythonProcess.environment() + QStringList("PYTHONVERBOSE=x"));
@@ -111,8 +116,11 @@ FilePath getPylsModulePath(CommandLine pylsCommand)
const QString &output = response.allOutput();
for (auto regex : {regexCached, regexNotCached}) {
QRegularExpressionMatch result = regex.match(output);
- if (result.hasMatch())
- return FilePath::fromUserInput(result.captured(1));
+ if (result.hasMatch()) {
+ const FilePath &modulePath = FilePath::fromUserInput(result.captured(1));
+ cache[pylsCommand.executable()] = modulePath;
+ return modulePath;
+ }
}
return {};
}
@@ -146,7 +154,7 @@ static PythonLanguageServerState checkPythonLanguageServer(const FilePath &pytho
}
}
- return {PythonLanguageServerState::AlreadyInstalled, getPylsModulePath(pythonLShelpCommand)};
+ return {PythonLanguageServerState::AlreadyInstalled, modulePath};
}
const CommandLine pythonPipVersionCommand(python, {"-m", "pip", "-V"});