From 99acc9a1535a6e4bb88658bcbd377fc660db2c51 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Thu, 9 Jun 2022 15:17:21 +0200 Subject: 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 --- src/plugins/python/pythonutils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins/python/pythonutils.cpp') 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 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; -- cgit v1.2.1