forked from qt-creator/qt-creator
ProjectExplorer: Upstream CMake's handling of outdated builds
This is mainly there to make the local runconfiguration implementations more uniform. Both qmake and qbs will drop runconfigs for builds that are not available anymore, so that's a no-op for them. Change-Id: I8aa32d779f67cce7a4d4733cfbe0c9a136bfd3f7 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -73,28 +73,6 @@ void CMakeRunConfiguration::doAdditionalSetup(const RunConfigurationCreationInfo
|
||||
updateTargetInformation();
|
||||
}
|
||||
|
||||
bool CMakeRunConfiguration::isBuildTargetValid() const
|
||||
{
|
||||
return Utils::anyOf(target()->applicationTargets().list, [this](const BuildTargetInfo &bti) {
|
||||
return bti.buildKey == buildKey();
|
||||
});
|
||||
}
|
||||
|
||||
void CMakeRunConfiguration::updateEnabledState()
|
||||
{
|
||||
if (!isBuildTargetValid())
|
||||
setEnabled(false);
|
||||
else
|
||||
RunConfiguration::updateEnabledState();
|
||||
}
|
||||
|
||||
QString CMakeRunConfiguration::disabledReason() const
|
||||
{
|
||||
if (!isBuildTargetValid())
|
||||
return tr("The project no longer builds the target associated with this run configuration.");
|
||||
return RunConfiguration::disabledReason();
|
||||
}
|
||||
|
||||
void CMakeRunConfiguration::updateTargetInformation()
|
||||
{
|
||||
BuildTargetInfo bti = buildTargetInfo();
|
||||
|
@@ -38,13 +38,8 @@ public:
|
||||
CMakeRunConfiguration(ProjectExplorer::Target *target, Core::Id id);
|
||||
|
||||
private:
|
||||
QString disabledReason() const override;
|
||||
|
||||
void doAdditionalSetup(const ProjectExplorer::RunConfigurationCreationInfo &) override;
|
||||
bool isBuildTargetValid() const;
|
||||
void updateTargetInformation();
|
||||
|
||||
void updateEnabledState() final;
|
||||
};
|
||||
|
||||
class CMakeRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory
|
||||
|
@@ -214,6 +214,8 @@ bool RunConfiguration::isActive() const
|
||||
|
||||
QString RunConfiguration::disabledReason() const
|
||||
{
|
||||
if (!target()->hasBuildTarget(m_buildKey))
|
||||
return tr("The project no longer builds the target associated with this run configuration.");
|
||||
if (target()->project()->isParsing())
|
||||
return tr("The Project is currently being parsed.");
|
||||
if (!target()->project()->hasParsingData())
|
||||
@@ -243,9 +245,14 @@ QWidget *RunConfiguration::createConfigurationWidget()
|
||||
|
||||
void RunConfiguration::updateEnabledState()
|
||||
{
|
||||
Project *p = target()->project();
|
||||
|
||||
setEnabled(!p->isParsing() && p->hasParsingData());
|
||||
if (!target()->hasBuildTarget(m_buildKey)) {
|
||||
// This apparently may happen for cmake builds where also outdated
|
||||
// RunConfigurations are kept when builds change.
|
||||
setEnabled(false); // Might happen for CMake.
|
||||
} else {
|
||||
Project *p = target()->project();
|
||||
setEnabled(!p->isParsing() && p->hasParsingData());
|
||||
}
|
||||
}
|
||||
|
||||
void RunConfiguration::addAspectFactory(const AspectFactory &aspectFactory)
|
||||
|
@@ -365,6 +365,13 @@ BuildTargetInfo Target::buildTarget(const QString &buildKey) const
|
||||
});
|
||||
}
|
||||
|
||||
bool Target::hasBuildTarget(const QString &buildKey) const
|
||||
{
|
||||
return Utils::anyOf(d->m_appTargets.list, [buildKey](const BuildTargetInfo &bti) {
|
||||
return bti.buildKey == buildKey;
|
||||
});
|
||||
}
|
||||
|
||||
QList<ProjectConfiguration *> Target::projectConfigurations() const
|
||||
{
|
||||
QList<ProjectConfiguration *> result;
|
||||
|
@@ -84,6 +84,7 @@ public:
|
||||
void setApplicationTargets(const BuildTargetInfoList &appTargets);
|
||||
BuildTargetInfoList applicationTargets() const;
|
||||
BuildTargetInfo buildTarget(const QString &buildKey) const;
|
||||
bool hasBuildTarget(const QString &buildKey) const;
|
||||
|
||||
QList<ProjectConfiguration *> projectConfigurations() const;
|
||||
|
||||
|
Reference in New Issue
Block a user