diff options
author | David Schulz <david.schulz@qt.io> | 2022-06-16 15:09:39 +0200 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2022-06-20 06:16:08 +0000 |
commit | 3b8b247f88f3a97bdd69f6ea058ed439f9b8648b (patch) | |
tree | 4cd01db1520b45bbd8ea6fb5bf03fc5ba1d289c0 /src/plugins/python/pythonutils.cpp | |
parent | 498418bbc9a73e7cace534fa237479a08901ccd9 (diff) | |
download | qt-creator-3b8b247f88f3a97bdd69f6ea058ed439f9b8648b.tar.gz |
Python: ignore windows store redirectors
Change-Id: Ife5c13549d73156550a7ce4b5436f1e5a19503fa
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/python/pythonutils.cpp')
-rw-r--r-- | src/plugins/python/pythonutils.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp index 08c8750c21..ebc2a695f7 100644 --- a/src/plugins/python/pythonutils.cpp +++ b/src/plugins/python/pythonutils.cpp @@ -74,13 +74,22 @@ FilePath detectPython(const FilePath &documentPath) if (defaultInterpreter.exists()) return defaultInterpreter; - const FilePath python3FromPath = env.searchInPath("python3"); - if (python3FromPath.exists()) - return python3FromPath; + auto pythonFromPath = [=](const QString toCheck) { + for (const FilePath &python : env.findAllInPath(toCheck)) { + // Windows creates empty redirector files that may interfere + if (python.exists() && python.osType() == OsTypeWindows && python.fileSize() != 0) + return python; + } + return FilePath(); + }; + + const FilePath fromPath3 = pythonFromPath("python3"); + if (fromPath3.exists()) + return fromPath3; - const FilePath pythonFromPath = env.searchInPath("python"); - if (pythonFromPath.exists()) - return pythonFromPath; + const FilePath fromPath = pythonFromPath("python"); + if (fromPath.exists()) + return fromPath; return PythonSettings::interpreters().value(0).command; } |