diff options
author | David Schulz <david.schulz@qt.io> | 2022-06-09 15:17:21 +0200 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2022-06-10 12:47:29 +0000 |
commit | 99acc9a1535a6e4bb88658bcbd377fc660db2c51 (patch) | |
tree | ef141e179da9bd8bf650e649c6717d5118c14c6b /src/plugins/python/pythonutils.cpp | |
parent | 4c20a880e6395f43e5fc9770c53c1034d08847a4 (diff) | |
download | qt-creator-99acc9a1535a6e4bb88658bcbd377fc660db2c51.tar.gz |
Python: Fix python detection for non project files
Do not return an empty file path if we cannot find a python venv for a
file path, but also consider the configured interpreters.
Change-Id: I5a7f06e394fb925f9a00143fc5f0797e8754534b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/python/pythonutils.cpp')
-rw-r--r-- | src/plugins/python/pythonutils.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp index 6c8ff9bcba..ae4fd3a1f7 100644 --- a/src/plugins/python/pythonutils.cpp +++ b/src/plugins/python/pythonutils.cpp @@ -67,8 +67,8 @@ FilePath detectPython(const FilePath &documentPath) // check whether this file is inside a python virtual environment QList<Interpreter> venvInterpreters = PythonSettings::detectPythonVenvs(documentPath); - if (!python.exists()) - python = venvInterpreters.value(0).command; + if (!python.exists() && !venvInterpreters.isEmpty()) + python = venvInterpreters.first().command; if (!python.exists()) python = PythonSettings::defaultInterpreter().command; |