From 061896a1480b4edea47d2f8cbdfc11e6484f8154 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 24 May 2019 14:31:34 +0200 Subject: [PATCH] ProjectExplorer: Add an official way to connect aspects Aspects are not completely orthogonal, e.g. working directory depends usually on environment etc. So far handling this used ad-hoc set up in the (Run)Configuration constructor. Lets make this an official second phase, that also reduces the need to use a specific construction order of aspects. Change-Id: Ic98b7d4e1ac9d46a32ec624bbbbfbbc32a40ab32 Reviewed-by: Christian Kandeler --- src/plugins/projectexplorer/projectconfiguration.cpp | 6 ++++++ src/plugins/projectexplorer/projectconfiguration.h | 4 ++++ src/plugins/projectexplorer/runconfiguration.cpp | 2 ++ 3 files changed, 12 insertions(+) diff --git a/src/plugins/projectexplorer/projectconfiguration.cpp b/src/plugins/projectexplorer/projectconfiguration.cpp index 73c715f0724..3d05c9ff870 100644 --- a/src/plugins/projectexplorer/projectconfiguration.cpp +++ b/src/plugins/projectexplorer/projectconfiguration.cpp @@ -181,6 +181,12 @@ ProjectConfigurationAspect *ProjectConfiguration::aspect(Core::Id id) const return m_aspects.aspect(id); } +void ProjectConfiguration::acquaintAspects() +{ + for (ProjectConfigurationAspect *aspect : m_aspects) + aspect->acquaintSiblings(m_aspects); +} + Core::Id ProjectExplorer::idFromMap(const QVariantMap &map) { return Core::Id::fromSetting(map.value(QLatin1String(CONFIGURATION_ID_KEY))); diff --git a/src/plugins/projectexplorer/projectconfiguration.h b/src/plugins/projectexplorer/projectconfiguration.h index 5e6952a1fb0..2d5be2299d3 100644 --- a/src/plugins/projectexplorer/projectconfiguration.h +++ b/src/plugins/projectexplorer/projectconfiguration.h @@ -41,6 +41,7 @@ QT_END_NAMESPACE namespace ProjectExplorer { class Project; +class ProjectConfigurationAspects; class PROJECTEXPLORER_EXPORT ProjectConfigurationAspect : public QObject { @@ -68,6 +69,7 @@ public: virtual void fromMap(const QVariantMap &) {} virtual void toMap(QVariantMap &) const {} virtual void addToConfigurationLayout(QFormLayout *) {} + virtual void acquaintSiblings(const ProjectConfigurationAspects &) {} signals: void changed(); @@ -168,6 +170,8 @@ public: ProjectConfigurationAspect *aspect(Core::Id id) const; template T *aspect() const { return m_aspects.aspect(); } + void acquaintAspects(); + signals: void displayNameChanged(); void toolTipChanged(); diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index f29564de56e..56b5d68bc24 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -554,6 +554,7 @@ RunConfiguration *RunConfigurationCreationInfo::create(Target *target) const if (!rc) return nullptr; + rc->acquaintAspects(); rc->m_buildKey = buildKey; rc->doAdditionalSetup(*this); rc->setDisplayName(displayName); @@ -569,6 +570,7 @@ RunConfiguration *RunConfigurationFactory::restore(Target *parent, const QVarian if (id.name().startsWith(factory->m_runConfigBaseId.name())) { QTC_ASSERT(factory->m_creator, continue); RunConfiguration *rc = factory->m_creator(parent); + rc->acquaintAspects(); if (rc->fromMap(map)) return rc; delete rc;