Commit b5c3b315 authored by Tobias Hunger's avatar Tobias Hunger

BuildInfo: Fix operator == to work better with subtypes

Different buildconfigurationfactories will always return different
BuildInfo, as the factories will turn the information into a different
set of objects (even if the information those objects are created from
are identical).

Each factory will always produce the same (sub-)type of BuildInfo, as
they need that information to proceed. So using the factory-address
as a kind of type-identifier is save.

Change-Id: Ia30355c26e045d453c0c2b75da893a4bac38b048
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 32468cf0
......@@ -55,6 +55,16 @@ public:
configuration = bc->cmakeConfiguration();
}
bool operator==(const BuildInfo &o) const final
{
if (!ProjectExplorer::BuildInfo::operator==(o))
return false;
auto other = static_cast<const CMakeBuildInfo *>(&o);
return sourceDirectory == other->sourceDirectory
&& configuration == other->configuration;
}
QString sourceDirectory;
CMakeConfig configuration;
};
......
......@@ -177,4 +177,10 @@ QString CMakeConfigItem::toString() const
return QString::fromUtf8(key) + QLatin1Char(':') + typeStr + QLatin1Char('=') + QString::fromUtf8(value);
}
bool CMakeConfigItem::operator==(const CMakeConfigItem &o) const
{
// type, isAdvanced and documentation do not matter for a match!
return o.key == key && o.value == value;
}
} // namespace CMakeProjectManager
......@@ -53,6 +53,8 @@ public:
static CMakeConfigItem fromString(const QString &s);
QString toString() const;
bool operator==(const CMakeConfigItem &o) const;
QByteArray key;
Type type = STRING;
bool isAdvanced = false;
......
......@@ -51,9 +51,10 @@ public:
Core::Id kitId;
BuildConfiguration::BuildType buildType = BuildConfiguration::Unknown;
bool operator==(const BuildInfo &o)
virtual bool operator==(const BuildInfo &o) const
{
return displayName == o.displayName && typeName == o.typeName
return m_factory == o.m_factory
&& displayName == o.displayName && typeName == o.typeName
&& buildDirectory == o.buildDirectory && kitId == o.kitId
&& buildType == o.buildType;
}
......
......@@ -44,11 +44,15 @@ public:
QString makefile;
QMakeStepConfig config;
bool operator==(const QmakeBuildInfo &o)
bool operator==(const BuildInfo &o) const final
{
return ProjectExplorer::BuildInfo::operator==(o)
&& additionalArguments == o.additionalArguments
&& config == o.config;
if (!ProjectExplorer::BuildInfo::operator==(o))
return false;
auto other = static_cast<const QmakeBuildInfo *>(&o);
return additionalArguments == other->additionalArguments
&& makefile == other->makefile
&& config == other->config;
}
QList<ProjectExplorer::Task> reportIssues(const QString &projectPath,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment