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 <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2022-04-13 16:14:03 +02:00
parent 2a39f35983
commit 5da8695dca
19 changed files with 28 additions and 46 deletions

View File

@@ -591,12 +591,6 @@ QVariant BaseAspect::fromSettingsValue(const QVariant &val) const
return d->m_fromSettings ? d->m_fromSettings(val) : val; return d->m_fromSettings ? d->m_fromSettings(val) : val;
} }
/*!
\internal
*/
void BaseAspect::acquaintSiblings(const AspectContainer &)
{}
namespace Internal { namespace Internal {
class BoolAspectPrivate class BoolAspectPrivate

View File

@@ -117,7 +117,6 @@ public:
virtual void fromMap(const QVariantMap &map); virtual void fromMap(const QVariantMap &map);
virtual void toMap(QVariantMap &map) const; virtual void toMap(QVariantMap &map) const;
virtual void toActiveMap(QVariantMap &map) const { toMap(map); } virtual void toActiveMap(QVariantMap &map) const { toMap(map); }
virtual void acquaintSiblings(const AspectContainer &);
virtual void addToLayout(LayoutBuilder &builder); virtual void addToLayout(LayoutBuilder &builder);

View File

@@ -53,7 +53,7 @@ public:
exeAspect->setPlaceHolderText(tr("Unknown")); exeAspect->setPlaceHolderText(tr("Unknown"));
addAspect<ArgumentsAspect>(); addAspect<ArgumentsAspect>();
addAspect<WorkingDirectoryAspect>(); addAspect<WorkingDirectoryAspect>(nullptr);
setUpdater([this, exeAspect] { setUpdater([this, exeAspect] {
const BuildTargetInfo bti = buildTargetInfo(); const BuildTargetInfo bti = buildTargetInfo();
@@ -80,7 +80,7 @@ public:
exeAspect->setExpectedKind(PathChooser::Any); exeAspect->setExpectedKind(PathChooser::Any);
addAspect<ArgumentsAspect>(); addAspect<ArgumentsAspect>();
addAspect<WorkingDirectoryAspect>(); addAspect<WorkingDirectoryAspect>(nullptr);
setDefaultDisplayName(RunConfigurationFactory::decoratedTargetName(tr("Custom Executable"), target)); setDefaultDisplayName(RunConfigurationFactory::decoratedTargetName(tr("Custom Executable"), target));
} }

View File

@@ -100,9 +100,10 @@ QdbRunConfiguration::QdbRunConfiguration(Target *target, Utils::Id id)
symbolsAspect->setLabelText(tr("Executable on host:")); symbolsAspect->setLabelText(tr("Executable on host:"));
symbolsAspect->setDisplayStyle(SymbolFileAspect::LabelDisplay); symbolsAspect->setDisplayStyle(SymbolFileAspect::LabelDisplay);
addAspect<RemoteLinux::RemoteLinuxEnvironmentAspect>(target); auto envAspect = addAspect<RemoteLinux::RemoteLinuxEnvironmentAspect>(target);
addAspect<ArgumentsAspect>(); addAspect<ArgumentsAspect>();
addAspect<WorkingDirectoryAspect>(); addAspect<WorkingDirectoryAspect>(envAspect);
addAspect<FullCommandLineAspect>(this); addAspect<FullCommandLineAspect>(this);
setUpdater([this, target, exeAspect, symbolsAspect] { setUpdater([this, target, exeAspect, symbolsAspect] {

View File

@@ -46,7 +46,7 @@ MesonRunConfiguration::MesonRunConfiguration(ProjectExplorer::Target *target, Ut
addAspect<ProjectExplorer::ExecutableAspect>(); addAspect<ProjectExplorer::ExecutableAspect>();
addAspect<ProjectExplorer::ArgumentsAspect>(); addAspect<ProjectExplorer::ArgumentsAspect>();
addAspect<ProjectExplorer::WorkingDirectoryAspect>(); addAspect<ProjectExplorer::WorkingDirectoryAspect>(envAspect);
addAspect<ProjectExplorer::TerminalAspect>(); addAspect<ProjectExplorer::TerminalAspect>();
auto libAspect = addAspect<ProjectExplorer::UseLibraryPathsAspect>(); auto libAspect = addAspect<ProjectExplorer::UseLibraryPathsAspect>();

View File

@@ -51,10 +51,10 @@ public:
NimbleRunConfiguration(Target *target, Utils::Id id) NimbleRunConfiguration(Target *target, Utils::Id id)
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
addAspect<LocalEnvironmentAspect>(target); auto envAspect = addAspect<LocalEnvironmentAspect>(target);
addAspect<ExecutableAspect>(); addAspect<ExecutableAspect>();
addAspect<ArgumentsAspect>(); addAspect<ArgumentsAspect>();
addAspect<WorkingDirectoryAspect>(); addAspect<WorkingDirectoryAspect>(envAspect);
addAspect<TerminalAspect>(); addAspect<TerminalAspect>();
setUpdater([this] { setUpdater([this] {
@@ -91,7 +91,7 @@ public:
{ {
addAspect<ExecutableAspect>()->setExecutable(Nim::nimblePathFromKit(target->kit())); addAspect<ExecutableAspect>()->setExecutable(Nim::nimblePathFromKit(target->kit()));
addAspect<ArgumentsAspect>()->setArguments("test"); addAspect<ArgumentsAspect>()->setArguments("test");
addAspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(project()->projectDirectory()); addAspect<WorkingDirectoryAspect>(nullptr)->setDefaultWorkingDirectory(project()->projectDirectory());
addAspect<TerminalAspect>(); addAspect<TerminalAspect>();
setDisplayName(tr("Nimble Test")); setDisplayName(tr("Nimble Test"));

View File

@@ -49,10 +49,10 @@ public:
NimRunConfiguration(Target *target, Utils::Id id) NimRunConfiguration(Target *target, Utils::Id id)
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
addAspect<LocalEnvironmentAspect>(target); auto envAspect = addAspect<LocalEnvironmentAspect>(target);
addAspect<ExecutableAspect>(); addAspect<ExecutableAspect>();
addAspect<ArgumentsAspect>(); addAspect<ArgumentsAspect>();
addAspect<WorkingDirectoryAspect>(); addAspect<WorkingDirectoryAspect>(envAspect);
addAspect<TerminalAspect>(); addAspect<TerminalAspect>();
setDisplayName(tr("Current Build Target")); setDisplayName(tr("Current Build Target"));

View File

@@ -302,8 +302,6 @@ void BuildConfiguration::doInitialize(const BuildInfo &info)
for (Utils::Id id : qAsConst(d->m_initialCleanSteps)) for (Utils::Id id : qAsConst(d->m_initialCleanSteps))
d->m_cleanSteps.appendStep(id); d->m_cleanSteps.appendStep(id);
acquaintAspects();
if (d->m_initializer) if (d->m_initializer)
d->m_initializer(info); d->m_initializer(info);
} }
@@ -791,7 +789,6 @@ BuildConfiguration *BuildConfigurationFactory::restore(Target *parent, const QVa
if (!id.name().startsWith(factory->m_buildConfigId.name())) if (!id.name().startsWith(factory->m_buildConfigId.name()))
continue; continue;
BuildConfiguration *bc = factory->m_creator(parent); BuildConfiguration *bc = factory->m_creator(parent);
bc->acquaintAspects();
QTC_ASSERT(bc, return nullptr); QTC_ASSERT(bc, return nullptr);
if (!bc->fromMap(map)) { if (!bc->fromMap(map)) {
delete bc; delete bc;

View File

@@ -54,7 +54,7 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *targe
exeAspect->setEnvironmentChange(EnvironmentChange::fromFixedEnvironment(envAspect->environment())); exeAspect->setEnvironmentChange(EnvironmentChange::fromFixedEnvironment(envAspect->environment()));
addAspect<ArgumentsAspect>(); addAspect<ArgumentsAspect>();
addAspect<WorkingDirectoryAspect>(); addAspect<WorkingDirectoryAspect>(envAspect);
addAspect<TerminalAspect>(); addAspect<TerminalAspect>();
connect(envAspect, &EnvironmentAspect::environmentChanged, this, [exeAspect, envAspect] { connect(envAspect, &EnvironmentAspect::environmentChanged, this, [exeAspect, envAspect] {

View File

@@ -70,7 +70,7 @@ DesktopRunConfiguration::DesktopRunConfiguration(Target *target, Id id, Kind kin
addAspect<ExecutableAspect>(); addAspect<ExecutableAspect>();
addAspect<ArgumentsAspect>(); addAspect<ArgumentsAspect>();
addAspect<WorkingDirectoryAspect>(); addAspect<WorkingDirectoryAspect>(envAspect);
addAspect<TerminalAspect>(); addAspect<TerminalAspect>();
auto libAspect = addAspect<UseLibraryPathsAspect>(); auto libAspect = addAspect<UseLibraryPathsAspect>();

View File

@@ -140,12 +140,6 @@ Utils::BaseAspect *ProjectConfiguration::aspect(Utils::Id id) const
return m_aspects.aspect(id); return m_aspects.aspect(id);
} }
void ProjectConfiguration::acquaintAspects()
{
for (Utils::BaseAspect *aspect : m_aspects)
aspect->acquaintSiblings(m_aspects);
}
void ProjectConfiguration::doPostInit() void ProjectConfiguration::doPostInit()
{ {
for (const std::function<void()> &postInit : qAsConst(m_postInit)) for (const std::function<void()> &postInit : qAsConst(m_postInit))

View File

@@ -87,8 +87,6 @@ public:
Utils::BaseAspect *aspect(Utils::Id id) const; Utils::BaseAspect *aspect(Utils::Id id) const;
template <typename T> T *aspect() const { return m_aspects.aspect<T>(); } template <typename T> T *aspect() const { return m_aspects.aspect<T>(); }
void acquaintAspects();
Utils::FilePath mapFromBuildDeviceToGlobalPath(const Utils::FilePath &path) const; Utils::FilePath mapFromBuildDeviceToGlobalPath(const Utils::FilePath &path) const;
void addPostInit(const std::function<void()> &fixup) { m_postInit.append(fixup); } void addPostInit(const std::function<void()> &fixup) { m_postInit.append(fixup); }

View File

@@ -584,7 +584,6 @@ RunConfiguration *RunConfigurationFactory::create(Target *target) const
for (const RunConfiguration::AspectFactory &factory : theAspectFactories) for (const RunConfiguration::AspectFactory &factory : theAspectFactories)
rc->m_aspects.registerAspect(factory(target)); rc->m_aspects.registerAspect(factory(target));
rc->acquaintAspects();
rc->doPostInit(); rc->doPostInit();
return rc; return rc;
} }

View File

@@ -164,7 +164,8 @@ bool TerminalAspect::isUserSet() const
working directory for running the executable. working directory for running the executable.
*/ */
WorkingDirectoryAspect::WorkingDirectoryAspect() WorkingDirectoryAspect::WorkingDirectoryAspect(EnvironmentAspect *envAspect)
: m_envAspect(envAspect)
{ {
setDisplayName(tr("Working Directory")); setDisplayName(tr("Working Directory"));
setId("WorkingDirectoryAspect"); setId("WorkingDirectoryAspect");
@@ -207,11 +208,6 @@ void WorkingDirectoryAspect::addToLayout(LayoutBuilder &builder)
builder.addItems({tr("Working directory:"), m_chooser.data(), m_resetButton.data()}); builder.addItems({tr("Working directory:"), m_chooser.data(), m_resetButton.data()});
} }
void WorkingDirectoryAspect::acquaintSiblings(const AspectContainer &siblings)
{
m_envAspect = siblings.aspect<EnvironmentAspect>();
}
void WorkingDirectoryAspect::resetPath() void WorkingDirectoryAspect::resetPath()
{ {
m_chooser->setFilePath(m_defaultWorkingDirectory); m_chooser->setFilePath(m_defaultWorkingDirectory);

View File

@@ -41,6 +41,8 @@ namespace Utils { class ExpandButton; }
namespace ProjectExplorer { namespace ProjectExplorer {
class ProjectConfiguration;
class PROJECTEXPLORER_EXPORT TerminalAspect : public Utils::BaseAspect class PROJECTEXPLORER_EXPORT TerminalAspect : public Utils::BaseAspect
{ {
Q_OBJECT Q_OBJECT
@@ -78,10 +80,9 @@ class PROJECTEXPLORER_EXPORT WorkingDirectoryAspect : public Utils::BaseAspect
Q_OBJECT Q_OBJECT
public: public:
WorkingDirectoryAspect(); explicit WorkingDirectoryAspect(EnvironmentAspect *envAspect);
void addToLayout(Utils::LayoutBuilder &builder) override; void addToLayout(Utils::LayoutBuilder &builder) override;
void acquaintSiblings(const Utils::AspectContainer &) override;
Utils::FilePath workingDirectory() const; Utils::FilePath workingDirectory() const;
Utils::FilePath defaultWorkingDirectory() const; Utils::FilePath defaultWorkingDirectory() const;

View File

@@ -277,7 +277,7 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Utils::Id id)
auto argumentsAspect = addAspect<ArgumentsAspect>(); auto argumentsAspect = addAspect<ArgumentsAspect>();
addAspect<WorkingDirectoryAspect>(); addAspect<WorkingDirectoryAspect>(nullptr);
addAspect<TerminalAspect>(); addAspect<TerminalAspect>();
setCommandLineGetter([this, bufferedAspect, interpreterAspect, argumentsAspect] { setCommandLineGetter([this, bufferedAspect, interpreterAspect, argumentsAspect] {

View File

@@ -59,10 +59,11 @@ QnxRunConfiguration::QnxRunConfiguration(Target *target, Utils::Id id)
symbolsAspect->setLabelText(tr("Executable on host:")); symbolsAspect->setLabelText(tr("Executable on host:"));
symbolsAspect->setDisplayStyle(SymbolFileAspect::LabelDisplay); symbolsAspect->setDisplayStyle(SymbolFileAspect::LabelDisplay);
auto envAspect = addAspect<RemoteLinuxEnvironmentAspect>(target);
addAspect<ArgumentsAspect>(); addAspect<ArgumentsAspect>();
addAspect<WorkingDirectoryAspect>(); addAspect<WorkingDirectoryAspect>(envAspect);
addAspect<TerminalAspect>(); addAspect<TerminalAspect>();
addAspect<RemoteLinuxEnvironmentAspect>(target);
auto libAspect = addAspect<StringAspect>(); auto libAspect = addAspect<StringAspect>();
libAspect->setSettingsKey("Qt4ProjectManager.QnxRunConfiguration.QtLibPath"); libAspect->setSettingsKey("Qt4ProjectManager.QnxRunConfiguration.QtLibPath");

View File

@@ -57,6 +57,8 @@ private:
RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *target, Id id) RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *target, Id id)
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
auto envAspect = addAspect<RemoteLinuxEnvironmentAspect>(target);
auto exeAspect = addAspect<ExecutableAspect>(); auto exeAspect = addAspect<ExecutableAspect>();
exeAspect->setSettingsKey("RemoteLinux.CustomRunConfig.RemoteExecutable"); exeAspect->setSettingsKey("RemoteLinux.CustomRunConfig.RemoteExecutable");
exeAspect->setLabelText(tr("Remote executable:")); exeAspect->setLabelText(tr("Remote executable:"));
@@ -71,10 +73,9 @@ RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *tar
symbolsAspect->setDisplayStyle(SymbolFileAspect::PathChooserDisplay); symbolsAspect->setDisplayStyle(SymbolFileAspect::PathChooserDisplay);
addAspect<ArgumentsAspect>(); addAspect<ArgumentsAspect>();
addAspect<WorkingDirectoryAspect>(); addAspect<WorkingDirectoryAspect>(envAspect);
if (HostOsInfo::isAnyUnixHost()) if (HostOsInfo::isAnyUnixHost())
addAspect<TerminalAspect>(); addAspect<TerminalAspect>();
addAspect<RemoteLinuxEnvironmentAspect>(target);
if (HostOsInfo::isAnyUnixHost()) if (HostOsInfo::isAnyUnixHost())
addAspect<X11ForwardingAspect>(); addAspect<X11ForwardingAspect>();

View File

@@ -57,6 +57,8 @@ public:
RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id) RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id)
: RunConfiguration(target, id) : RunConfiguration(target, id)
{ {
auto envAspect = addAspect<RemoteLinuxEnvironmentAspect>(target);
auto exeAspect = addAspect<ExecutableAspect>(); auto exeAspect = addAspect<ExecutableAspect>();
exeAspect->setLabelText(tr("Executable on device:")); exeAspect->setLabelText(tr("Executable on device:"));
exeAspect->setExecutablePathStyle(OsTypeLinux); exeAspect->setExecutablePathStyle(OsTypeLinux);
@@ -70,10 +72,9 @@ RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id)
symbolsAspect->setDisplayStyle(SymbolFileAspect::LabelDisplay); symbolsAspect->setDisplayStyle(SymbolFileAspect::LabelDisplay);
addAspect<ArgumentsAspect>(); addAspect<ArgumentsAspect>();
addAspect<WorkingDirectoryAspect>(); addAspect<WorkingDirectoryAspect>(envAspect);
if (HostOsInfo::isAnyUnixHost()) if (HostOsInfo::isAnyUnixHost())
addAspect<TerminalAspect>(); addAspect<TerminalAspect>();
addAspect<RemoteLinuxEnvironmentAspect>(target);
if (HostOsInfo::isAnyUnixHost()) if (HostOsInfo::isAnyUnixHost())
addAspect<X11ForwardingAspect>(); addAspect<X11ForwardingAspect>();