From dd93820fdd550e21c6e1f0c6eaaae11afdb8fc51 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Thu, 14 Nov 2019 15:43:05 +0100 Subject: [PATCH] Python: Restrict creating run configurations Some upcoming wizards will have other files beside python scripts. (e.g. qml, ui) Ensure that these files do not get a run configuration. Change-Id: I0fe55edc6ccfe2db64537401e6a46fd4bdd7e153 Reviewed-by: hjk --- src/plugins/python/pythonproject.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/plugins/python/pythonproject.cpp b/src/plugins/python/pythonproject.cpp index 921f66b0437..892b9f144f8 100644 --- a/src/plugins/python/pythonproject.cpp +++ b/src/plugins/python/pythonproject.cpp @@ -205,14 +205,20 @@ void PythonBuildSystem::refresh() auto newRoot = std::make_unique(projectDirectory()); for (const QString &f : qAsConst(m_files)) { const QString displayName = baseDir.relativeFilePath(f); - const FileType fileType = f.endsWith(".pyproject") || f.endsWith(".pyqtc") ? FileType::Project - : FileType::Source; - newRoot->addNestedNode(std::make_unique(FilePath::fromString(f), - displayName, fileType)); + const FilePath filePath = FilePath::fromString(f); + FileType fileType; + if (f.endsWith(".py")) + fileType = FileType::Source; + else if (f.endsWith(".pyproject") || f.endsWith(".pyqtc")) + fileType = FileType::Project; + else + fileType = Node::fileTypeForFileName(filePath); + + newRoot->addNestedNode(std::make_unique(filePath, displayName, fileType)); if (fileType == FileType::Source) { BuildTargetInfo bti; bti.buildKey = f; - bti.targetFilePath = FilePath::fromString(f); + bti.targetFilePath = filePath; bti.projectFilePath = projectFilePath(); appTargets.append(bti); }