forked from qt-creator/qt-creator
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 <tim.jenssen@qt.io>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user