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 e4738904d9.

Fixes: QTCREATORBUG-23753
Change-Id: I0dbb296cd974a3530222661c4b8cecc2106f0ea5
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
Christian Kandeler
2020-04-08 10:19:25 +02:00
parent 76617a5512
commit c0ea5736f3

View File

@@ -123,15 +123,6 @@ private:
QmakeProject manages information about an individual qmake project file (.pro). 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) : QmakeProject::QmakeProject(const FilePath &fileName) :
Project(QmakeProjectManager::Constants::PROFILE_MIMETYPE, 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)) if (!ToolChainKitAspect::toolChain(k, ProjectExplorer::Constants::CXX_LANGUAGE_ID))
result.append(createProjectTask(Task::TaskType::Error, tr("No C++ compiler set in kit."))); result.append(createProjectTask(Task::TaskType::Error, tr("No C++ compiler set in kit.")));
const QtSupport::BaseQtVersion *const qtThatContainsProject = projectIsPartOfQt(this); // A project can be considered part of more than one Qt version, for instance if it is an
if (qtThatContainsProject && qtThatContainsProject != qtFromKit) { // 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<BaseQtVersion *> qtsContainingThisProject
= QtVersionManager::versions([filePath = projectFilePath()](const BaseQtVersion *qt) {
return qt->isValid() && qt->isSubProject(filePath);
});
if (!qtsContainingThisProject.isEmpty()
&& !qtsContainingThisProject.contains(const_cast<BaseQtVersion *>(qtFromKit))) {
result.append(CompileTask(Task::Warning, result.append(CompileTask(Task::Warning,
tr("Project is part of Qt sources that do not match " tr("Project is part of Qt sources that do not match "
"the Qt defined in the kit."))); "the Qt defined in the kit.")));