From 5da8695dca9106f1176bef86e920f61ef3d20071 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 13 Apr 2022 16:14:03 +0200 Subject: [PATCH] ProjectExplorer: Pass envAspect directly to WorkingDirectory constructor This trades a now necessary order of setup for the now removed "acquaintSiblings" facility. Change-Id: I85058578b792e210f24573e2ab4e3a40a8813a11 Reviewed-by: David Schulz Reviewed-by: --- src/libs/utils/aspects.cpp | 6 ------ src/libs/utils/aspects.h | 1 - src/plugins/baremetal/baremetalrunconfiguration.cpp | 4 ++-- src/plugins/boot2qt/qdbrunconfiguration.cpp | 5 +++-- .../mesonprojectmanager/project/mesonrunconfiguration.cpp | 2 +- src/plugins/nim/project/nimblerunconfiguration.cpp | 6 +++--- src/plugins/nim/project/nimrunconfiguration.cpp | 4 ++-- src/plugins/projectexplorer/buildconfiguration.cpp | 3 --- .../projectexplorer/customexecutablerunconfiguration.cpp | 2 +- src/plugins/projectexplorer/desktoprunconfiguration.cpp | 2 +- src/plugins/projectexplorer/projectconfiguration.cpp | 6 ------ src/plugins/projectexplorer/projectconfiguration.h | 2 -- src/plugins/projectexplorer/runconfiguration.cpp | 1 - src/plugins/projectexplorer/runconfigurationaspects.cpp | 8 ++------ src/plugins/projectexplorer/runconfigurationaspects.h | 5 +++-- src/plugins/python/pythonrunconfiguration.cpp | 2 +- src/plugins/qnx/qnxrunconfiguration.cpp | 5 +++-- .../remotelinux/remotelinuxcustomrunconfiguration.cpp | 5 +++-- src/plugins/remotelinux/remotelinuxrunconfiguration.cpp | 5 +++-- 19 files changed, 28 insertions(+), 46 deletions(-) diff --git a/src/libs/utils/aspects.cpp b/src/libs/utils/aspects.cpp index ed496a163de..fc0fed11d60 100644 --- a/src/libs/utils/aspects.cpp +++ b/src/libs/utils/aspects.cpp @@ -591,12 +591,6 @@ QVariant BaseAspect::fromSettingsValue(const QVariant &val) const return d->m_fromSettings ? d->m_fromSettings(val) : val; } -/*! - \internal -*/ -void BaseAspect::acquaintSiblings(const AspectContainer &) -{} - namespace Internal { class BoolAspectPrivate diff --git a/src/libs/utils/aspects.h b/src/libs/utils/aspects.h index 6b83038cb13..810b8ef5c3e 100644 --- a/src/libs/utils/aspects.h +++ b/src/libs/utils/aspects.h @@ -117,7 +117,6 @@ public: virtual void fromMap(const QVariantMap &map); virtual void toMap(QVariantMap &map) const; virtual void toActiveMap(QVariantMap &map) const { toMap(map); } - virtual void acquaintSiblings(const AspectContainer &); virtual void addToLayout(LayoutBuilder &builder); diff --git a/src/plugins/baremetal/baremetalrunconfiguration.cpp b/src/plugins/baremetal/baremetalrunconfiguration.cpp index 913f1f3448f..03e588212b1 100644 --- a/src/plugins/baremetal/baremetalrunconfiguration.cpp +++ b/src/plugins/baremetal/baremetalrunconfiguration.cpp @@ -53,7 +53,7 @@ public: exeAspect->setPlaceHolderText(tr("Unknown")); addAspect(); - addAspect(); + addAspect(nullptr); setUpdater([this, exeAspect] { const BuildTargetInfo bti = buildTargetInfo(); @@ -80,7 +80,7 @@ public: exeAspect->setExpectedKind(PathChooser::Any); addAspect(); - addAspect(); + addAspect(nullptr); setDefaultDisplayName(RunConfigurationFactory::decoratedTargetName(tr("Custom Executable"), target)); } diff --git a/src/plugins/boot2qt/qdbrunconfiguration.cpp b/src/plugins/boot2qt/qdbrunconfiguration.cpp index 56dc0af8d62..0fce139afa4 100644 --- a/src/plugins/boot2qt/qdbrunconfiguration.cpp +++ b/src/plugins/boot2qt/qdbrunconfiguration.cpp @@ -100,9 +100,10 @@ QdbRunConfiguration::QdbRunConfiguration(Target *target, Utils::Id id) symbolsAspect->setLabelText(tr("Executable on host:")); symbolsAspect->setDisplayStyle(SymbolFileAspect::LabelDisplay); - addAspect(target); + auto envAspect = addAspect(target); + addAspect(); - addAspect(); + addAspect(envAspect); addAspect(this); setUpdater([this, target, exeAspect, symbolsAspect] { diff --git a/src/plugins/mesonprojectmanager/project/mesonrunconfiguration.cpp b/src/plugins/mesonprojectmanager/project/mesonrunconfiguration.cpp index a4590b41a1f..1384ddfda9b 100644 --- a/src/plugins/mesonprojectmanager/project/mesonrunconfiguration.cpp +++ b/src/plugins/mesonprojectmanager/project/mesonrunconfiguration.cpp @@ -46,7 +46,7 @@ MesonRunConfiguration::MesonRunConfiguration(ProjectExplorer::Target *target, Ut addAspect(); addAspect(); - addAspect(); + addAspect(envAspect); addAspect(); auto libAspect = addAspect(); diff --git a/src/plugins/nim/project/nimblerunconfiguration.cpp b/src/plugins/nim/project/nimblerunconfiguration.cpp index 1dcd9315ac2..fc5966c10e5 100644 --- a/src/plugins/nim/project/nimblerunconfiguration.cpp +++ b/src/plugins/nim/project/nimblerunconfiguration.cpp @@ -51,10 +51,10 @@ public: NimbleRunConfiguration(Target *target, Utils::Id id) : RunConfiguration(target, id) { - addAspect(target); + auto envAspect = addAspect(target); addAspect(); addAspect(); - addAspect(); + addAspect(envAspect); addAspect(); setUpdater([this] { @@ -91,7 +91,7 @@ public: { addAspect()->setExecutable(Nim::nimblePathFromKit(target->kit())); addAspect()->setArguments("test"); - addAspect()->setDefaultWorkingDirectory(project()->projectDirectory()); + addAspect(nullptr)->setDefaultWorkingDirectory(project()->projectDirectory()); addAspect(); setDisplayName(tr("Nimble Test")); diff --git a/src/plugins/nim/project/nimrunconfiguration.cpp b/src/plugins/nim/project/nimrunconfiguration.cpp index ef3e478b857..0d779a00364 100644 --- a/src/plugins/nim/project/nimrunconfiguration.cpp +++ b/src/plugins/nim/project/nimrunconfiguration.cpp @@ -49,10 +49,10 @@ public: NimRunConfiguration(Target *target, Utils::Id id) : RunConfiguration(target, id) { - addAspect(target); + auto envAspect = addAspect(target); addAspect(); addAspect(); - addAspect(); + addAspect(envAspect); addAspect(); setDisplayName(tr("Current Build Target")); diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp index 481c16be811..15f618a0f8a 100644 --- a/src/plugins/projectexplorer/buildconfiguration.cpp +++ b/src/plugins/projectexplorer/buildconfiguration.cpp @@ -302,8 +302,6 @@ void BuildConfiguration::doInitialize(const BuildInfo &info) for (Utils::Id id : qAsConst(d->m_initialCleanSteps)) d->m_cleanSteps.appendStep(id); - acquaintAspects(); - if (d->m_initializer) d->m_initializer(info); } @@ -791,7 +789,6 @@ BuildConfiguration *BuildConfigurationFactory::restore(Target *parent, const QVa if (!id.name().startsWith(factory->m_buildConfigId.name())) continue; BuildConfiguration *bc = factory->m_creator(parent); - bc->acquaintAspects(); QTC_ASSERT(bc, return nullptr); if (!bc->fromMap(map)) { delete bc; diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp index 80678ba841e..7a842b52ccb 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp @@ -54,7 +54,7 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *targe exeAspect->setEnvironmentChange(EnvironmentChange::fromFixedEnvironment(envAspect->environment())); addAspect(); - addAspect(); + addAspect(envAspect); addAspect(); connect(envAspect, &EnvironmentAspect::environmentChanged, this, [exeAspect, envAspect] { diff --git a/src/plugins/projectexplorer/desktoprunconfiguration.cpp b/src/plugins/projectexplorer/desktoprunconfiguration.cpp index d0ab573b06f..ef0bcec50d6 100644 --- a/src/plugins/projectexplorer/desktoprunconfiguration.cpp +++ b/src/plugins/projectexplorer/desktoprunconfiguration.cpp @@ -70,7 +70,7 @@ DesktopRunConfiguration::DesktopRunConfiguration(Target *target, Id id, Kind kin addAspect(); addAspect(); - addAspect(); + addAspect(envAspect); addAspect(); auto libAspect = addAspect(); diff --git a/src/plugins/projectexplorer/projectconfiguration.cpp b/src/plugins/projectexplorer/projectconfiguration.cpp index 3215f0bdb3f..eac18b43229 100644 --- a/src/plugins/projectexplorer/projectconfiguration.cpp +++ b/src/plugins/projectexplorer/projectconfiguration.cpp @@ -140,12 +140,6 @@ Utils::BaseAspect *ProjectConfiguration::aspect(Utils::Id id) const return m_aspects.aspect(id); } -void ProjectConfiguration::acquaintAspects() -{ - for (Utils::BaseAspect *aspect : m_aspects) - aspect->acquaintSiblings(m_aspects); -} - void ProjectConfiguration::doPostInit() { for (const std::function &postInit : qAsConst(m_postInit)) diff --git a/src/plugins/projectexplorer/projectconfiguration.h b/src/plugins/projectexplorer/projectconfiguration.h index 9263804c56a..64c9dffaad1 100644 --- a/src/plugins/projectexplorer/projectconfiguration.h +++ b/src/plugins/projectexplorer/projectconfiguration.h @@ -87,8 +87,6 @@ public: Utils::BaseAspect *aspect(Utils::Id id) const; template T *aspect() const { return m_aspects.aspect(); } - void acquaintAspects(); - Utils::FilePath mapFromBuildDeviceToGlobalPath(const Utils::FilePath &path) const; void addPostInit(const std::function &fixup) { m_postInit.append(fixup); } diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index d302bb5a7be..542bae58016 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -584,7 +584,6 @@ RunConfiguration *RunConfigurationFactory::create(Target *target) const for (const RunConfiguration::AspectFactory &factory : theAspectFactories) rc->m_aspects.registerAspect(factory(target)); - rc->acquaintAspects(); rc->doPostInit(); return rc; } diff --git a/src/plugins/projectexplorer/runconfigurationaspects.cpp b/src/plugins/projectexplorer/runconfigurationaspects.cpp index 08ae45d1775..7d770980c34 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/runconfigurationaspects.cpp @@ -164,7 +164,8 @@ bool TerminalAspect::isUserSet() const working directory for running the executable. */ -WorkingDirectoryAspect::WorkingDirectoryAspect() +WorkingDirectoryAspect::WorkingDirectoryAspect(EnvironmentAspect *envAspect) + : m_envAspect(envAspect) { setDisplayName(tr("Working Directory")); setId("WorkingDirectoryAspect"); @@ -207,11 +208,6 @@ void WorkingDirectoryAspect::addToLayout(LayoutBuilder &builder) builder.addItems({tr("Working directory:"), m_chooser.data(), m_resetButton.data()}); } -void WorkingDirectoryAspect::acquaintSiblings(const AspectContainer &siblings) -{ - m_envAspect = siblings.aspect(); -} - void WorkingDirectoryAspect::resetPath() { m_chooser->setFilePath(m_defaultWorkingDirectory); diff --git a/src/plugins/projectexplorer/runconfigurationaspects.h b/src/plugins/projectexplorer/runconfigurationaspects.h index 7426c82fa26..d7ba3a9ae6f 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.h +++ b/src/plugins/projectexplorer/runconfigurationaspects.h @@ -41,6 +41,8 @@ namespace Utils { class ExpandButton; } namespace ProjectExplorer { +class ProjectConfiguration; + class PROJECTEXPLORER_EXPORT TerminalAspect : public Utils::BaseAspect { Q_OBJECT @@ -78,10 +80,9 @@ class PROJECTEXPLORER_EXPORT WorkingDirectoryAspect : public Utils::BaseAspect Q_OBJECT public: - WorkingDirectoryAspect(); + explicit WorkingDirectoryAspect(EnvironmentAspect *envAspect); void addToLayout(Utils::LayoutBuilder &builder) override; - void acquaintSiblings(const Utils::AspectContainer &) override; Utils::FilePath workingDirectory() const; Utils::FilePath defaultWorkingDirectory() const; diff --git a/src/plugins/python/pythonrunconfiguration.cpp b/src/plugins/python/pythonrunconfiguration.cpp index 1bd7ccf6c0f..7425f439508 100644 --- a/src/plugins/python/pythonrunconfiguration.cpp +++ b/src/plugins/python/pythonrunconfiguration.cpp @@ -277,7 +277,7 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Utils::Id id) auto argumentsAspect = addAspect(); - addAspect(); + addAspect(nullptr); addAspect(); setCommandLineGetter([this, bufferedAspect, interpreterAspect, argumentsAspect] { diff --git a/src/plugins/qnx/qnxrunconfiguration.cpp b/src/plugins/qnx/qnxrunconfiguration.cpp index 02f61894b71..a5d34a85ae3 100644 --- a/src/plugins/qnx/qnxrunconfiguration.cpp +++ b/src/plugins/qnx/qnxrunconfiguration.cpp @@ -59,10 +59,11 @@ QnxRunConfiguration::QnxRunConfiguration(Target *target, Utils::Id id) symbolsAspect->setLabelText(tr("Executable on host:")); symbolsAspect->setDisplayStyle(SymbolFileAspect::LabelDisplay); + auto envAspect = addAspect(target); + addAspect(); - addAspect(); + addAspect(envAspect); addAspect(); - addAspect(target); auto libAspect = addAspect(); libAspect->setSettingsKey("Qt4ProjectManager.QnxRunConfiguration.QtLibPath"); diff --git a/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp b/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp index b3604332d17..34b37e9835c 100644 --- a/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp +++ b/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp @@ -57,6 +57,8 @@ private: RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *target, Id id) : RunConfiguration(target, id) { + auto envAspect = addAspect(target); + auto exeAspect = addAspect(); exeAspect->setSettingsKey("RemoteLinux.CustomRunConfig.RemoteExecutable"); exeAspect->setLabelText(tr("Remote executable:")); @@ -71,10 +73,9 @@ RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *tar symbolsAspect->setDisplayStyle(SymbolFileAspect::PathChooserDisplay); addAspect(); - addAspect(); + addAspect(envAspect); if (HostOsInfo::isAnyUnixHost()) addAspect(); - addAspect(target); if (HostOsInfo::isAnyUnixHost()) addAspect(); diff --git a/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp b/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp index c964d235cc5..6188629031b 100644 --- a/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp +++ b/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp @@ -57,6 +57,8 @@ public: RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id) : RunConfiguration(target, id) { + auto envAspect = addAspect(target); + auto exeAspect = addAspect(); exeAspect->setLabelText(tr("Executable on device:")); exeAspect->setExecutablePathStyle(OsTypeLinux); @@ -70,10 +72,9 @@ RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id) symbolsAspect->setDisplayStyle(SymbolFileAspect::LabelDisplay); addAspect(); - addAspect(); + addAspect(envAspect); if (HostOsInfo::isAnyUnixHost()) addAspect(); - addAspect(target); if (HostOsInfo::isAnyUnixHost()) addAspect();