From c0ea5736f3c225b253844c66da3732b304eee843 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Wed, 8 Apr 2020 10:19:25 +0200 Subject: [PATCH] Fix invalid reports about Qt <-> project mismatch For instance, the warning was potentially erroneously triggered with examples distributed via the installer, as those are present only once for different installations with the same version number. Amends e4738904d9bc. Fixes: QTCREATORBUG-23753 Change-Id: I0dbb296cd974a3530222661c4b8cecc2106f0ea5 Reviewed-by: Oliver Wolff --- .../qmakeprojectmanager/qmakeproject.cpp | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp index 8db751584c1..109b9d3d8e6 100644 --- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp @@ -123,15 +123,6 @@ private: QmakeProject manages information about an individual qmake project file (.pro). */ -static QtSupport::BaseQtVersion *projectIsPartOfQt(const Project *p) -{ - FilePath filePath = p->projectFilePath(); - - return QtSupport::QtVersionManager::version([&filePath](const QtSupport::BaseQtVersion *v) { - return v->isValid() && v->isSubProject(filePath); - }); -} - QmakeProject::QmakeProject(const FilePath &fileName) : Project(QmakeProjectManager::Constants::PROFILE_MIMETYPE, fileName) { @@ -623,8 +614,16 @@ Tasks QmakeProject::projectIssues(const Kit *k) const if (!ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID)) result.append(createProjectTask(Task::TaskType::Error, tr("No C++ compiler set in kit."))); - const QtSupport::BaseQtVersion *const qtThatContainsProject = projectIsPartOfQt(this); - if (qtThatContainsProject && qtThatContainsProject != qtFromKit) { + // A project can be considered part of more than one Qt version, for instance if it is an + // example shipped via the installer. + // Report a problem if and only if the project is considered to be part of *only* a Qt + // that is not the one from the current kit. + const QList qtsContainingThisProject + = QtVersionManager::versions([filePath = projectFilePath()](const BaseQtVersion *qt) { + return qt->isValid() && qt->isSubProject(filePath); + }); + if (!qtsContainingThisProject.isEmpty() + && !qtsContainingThisProject.contains(const_cast(qtFromKit))) { result.append(CompileTask(Task::Warning, tr("Project is part of Qt sources that do not match " "the Qt defined in the kit.")));