From 9b6bbc181b2e41e75fa0833ee48fb3696cec653d Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 16 Oct 2024 16:44:07 +0200 Subject: [PATCH] ProjectExplorer: Display build configuration specific variables again Continues d308b86847abad8. Task-number: QTCREATORBUG-31614 Change-Id: I408d96ccd6854b7bb62e13252c00ed3a29788b4c Reviewed-by: Christian Kandeler --- src/libs/utils/aspects.cpp | 50 ++++++++++++------- src/libs/utils/aspects.h | 7 +-- src/libs/utils/macroexpander.cpp | 5 ++ src/libs/utils/macroexpander.h | 3 +- .../android/androidrunconfiguration.cpp | 1 - src/plugins/axivion/axivionsettings.cpp | 1 - .../baremetal/baremetalrunconfiguration.cpp | 8 --- src/plugins/boot2qt/qdbrunconfiguration.cpp | 3 -- .../haskell/haskellrunconfiguration.cpp | 3 -- src/plugins/ios/iosrunconfiguration.cpp | 2 - .../mesonrunconfiguration.cpp | 3 -- src/plugins/nim/project/nimblebuildstep.cpp | 1 - .../nim/project/nimblerunconfiguration.cpp | 6 --- .../nim/project/nimrunconfiguration.cpp | 4 -- .../projectexplorer/buildconfiguration.cpp | 6 --- .../projectexplorer/buildconfiguration.h | 2 - src/plugins/projectexplorer/buildstep.cpp | 5 +- .../customexecutablerunconfiguration.cpp | 3 -- .../desktoprunconfiguration.cpp | 3 -- .../projectexplorer/runconfiguration.cpp | 19 ++++--- .../projectexplorer/runconfiguration.h | 1 - .../runconfigurationaspects.cpp | 16 +----- .../projectexplorer/runconfigurationaspects.h | 7 --- src/plugins/python/pythonrunconfiguration.cpp | 5 -- .../qbsprojectmanager/qbsbuildstep.cpp | 2 +- src/plugins/qmakeprojectmanager/qmakestep.cpp | 1 - .../qmlprojectrunconfiguration.cpp | 3 -- src/plugins/qnx/qnxrunconfiguration.cpp | 3 -- .../remotelinuxcustomrunconfiguration.cpp | 5 -- .../remotelinuxrunconfiguration.cpp | 5 -- 30 files changed, 58 insertions(+), 125 deletions(-) diff --git a/src/libs/utils/aspects.cpp b/src/libs/utils/aspects.cpp index 0eeb083d877..cc8a5aa625b 100644 --- a/src/libs/utils/aspects.cpp +++ b/src/libs/utils/aspects.cpp @@ -69,6 +69,24 @@ class Internal::BaseAspectPrivate public: explicit BaseAspectPrivate(AspectContainer *container) : m_container(container) {} + MacroExpander *macroExpander() + { + if (!m_expander) { + m_expander = std::make_unique(); + m_expander->setDisplayName("Variables"); + if (m_container) + m_expander->registerSubProvider([this] { return m_container->macroExpander(); }); + } + return m_expander.get(); + } + + void setContainer(AspectContainer *container) + { + m_container = container; + if (m_expander) + m_expander->registerSubProvider([this] { return m_container->macroExpander(); }); + } + Id m_id; std::function m_toSettings; std::function m_fromSettings; @@ -96,8 +114,10 @@ public: BaseAspect::DataCloner m_dataCloner; QList m_dataExtractors; - MacroExpander *m_expander = globalMacroExpander(); QUndoStack *m_undoStack = nullptr; + +private: + std::unique_ptr m_expander; }; /*! @@ -649,6 +669,11 @@ void BaseAspect::forEachSubWidget(const std::function &func) func(w); } +void BaseAspect::setContainer(AspectContainer *container) +{ + d->setContainer(container); +} + void BaseAspect::saveToMap(Store &data, const QVariant &value, const QVariant &defaultValue, const Key &key) { @@ -741,12 +766,14 @@ QVariant BaseAspect::fromSettingsValue(const QVariant &val) const void BaseAspect::setMacroExpander(MacroExpander *expander) { - d->m_expander = expander; + d->macroExpander()->clearSubProviders(); + if (expander) + d->macroExpander()->registerSubProvider([expander] { return expander; }); } MacroExpander *BaseAspect::macroExpander() const { - return d->m_expander; + return d->macroExpander(); } void BaseAspect::addOnChanged(QObject *guard, const Callback &callback) @@ -781,15 +808,11 @@ void BaseAspect::addOnLabelPixmapChanged(QObject *guard, const Callback &callbac void BaseAspect::addMacroExpansion(QWidget *w) { - if (!d->m_expander) - return; const auto chooser = new VariableChooser(w); chooser->addSupportedWidget(w); - if (d->m_expander == globalMacroExpander()) // default for VariableChooser() - return; - chooser->addMacroExpanderProvider([this] { return d->m_expander; }); + chooser->addMacroExpanderProvider([this] { return d->macroExpander(); }); if (auto pathChooser = qobject_cast(w)) - pathChooser->setMacroExpander(d->m_expander); + pathChooser->setMacroExpander(d->macroExpander()); } namespace Internal { @@ -3169,6 +3192,7 @@ void AspectContainer::addToLayoutImpl(Layouting::Layout &parent) */ void AspectContainer::registerAspect(BaseAspect *aspect, bool takeOwnership) { + aspect->setContainer(this); aspect->setAutoApply(isAutoApply()); aspect->setEnabled(isEnabled()); d->m_items.append(aspect); @@ -3333,14 +3357,6 @@ void AspectContainer::setEnabled(bool enabled) aspect->setEnabled(enabled); } -void AspectContainer::setMacroExpander(MacroExpander *expander) -{ - BaseAspect::setMacroExpander(expander); - - for (BaseAspect *aspect : std::as_const(d->m_items)) - aspect->setMacroExpander(expander); -} - bool AspectContainer::equals(const AspectContainer &other) const { // FIXME: Expensive, but should not really be needed in a fully aspectified world. diff --git a/src/libs/utils/aspects.h b/src/libs/utils/aspects.h index 6c3b62cdbe7..3fa54a2827d 100644 --- a/src/libs/utils/aspects.h +++ b/src/libs/utils/aspects.h @@ -286,8 +286,11 @@ protected: } private: - std::unique_ptr d; friend class Internal::CheckableAspectImplementation; + friend class AspectContainer; + void setContainer(AspectContainer *container); + + std::unique_ptr d; }; QTCREATOR_UTILS_EXPORT void addToLayout(Layouting::Layout *layout, const BaseAspect *aspect); @@ -999,8 +1002,6 @@ public: void setUndoStack(QUndoStack *undoStack) override; void setEnabled(bool enabled) override; - void setMacroExpander(MacroExpander *expander); - template T *aspect() const { for (BaseAspect *aspect : aspects()) diff --git a/src/libs/utils/macroexpander.cpp b/src/libs/utils/macroexpander.cpp index 51a38f4f8c6..d8bfd68ee3c 100644 --- a/src/libs/utils/macroexpander.cpp +++ b/src/libs/utils/macroexpander.cpp @@ -481,6 +481,11 @@ void MacroExpander::registerSubProvider(const MacroExpanderProvider &provider) d->m_subProviders.append(provider); } +void MacroExpander::clearSubProviders() +{ + d->m_subProviders.clear(); +} + bool MacroExpander::isAccumulating() const { return d->m_accumulating; diff --git a/src/libs/utils/macroexpander.h b/src/libs/utils/macroexpander.h index fe98d46872f..ad9a21a938b 100644 --- a/src/libs/utils/macroexpander.h +++ b/src/libs/utils/macroexpander.h @@ -23,7 +23,7 @@ class QTCREATOR_UTILS_EXPORT MacroExpander Q_DISABLE_COPY(MacroExpander) public: - explicit MacroExpander(); + MacroExpander(); ~MacroExpander(); bool resolveMacro(const QString &name, QString *ret) const; @@ -69,6 +69,7 @@ public: void setDisplayName(const QString &displayName); void registerSubProvider(const MacroExpanderProvider &provider); + void clearSubProviders(); bool isAccumulating() const; void setAccumulating(bool on); diff --git a/src/plugins/android/androidrunconfiguration.cpp b/src/plugins/android/androidrunconfiguration.cpp index 3b7da499440..14846d9ddf8 100644 --- a/src/plugins/android/androidrunconfiguration.cpp +++ b/src/plugins/android/androidrunconfiguration.cpp @@ -53,7 +53,6 @@ public: { environment.addSupportedBaseEnvironment(Tr::tr("Clean Environment"), {}); - extraAppArgs.setMacroExpander(macroExpander()); extraAppArgs.addOnChanged(this, [this, target] { if (target->buildConfigurations().first()->buildType() == BuildConfiguration::BuildType::Release) { const QString buildKey = target->activeBuildKey(); diff --git a/src/plugins/axivion/axivionsettings.cpp b/src/plugins/axivion/axivionsettings.cpp index ad121d1ae94..eb6369410e3 100644 --- a/src/plugins/axivion/axivionsettings.cpp +++ b/src/plugins/axivion/axivionsettings.cpp @@ -562,7 +562,6 @@ public: &m_localPath, noMargin}; }); - setMacroExpander(nullptr); } void updateContent(const PathMapping &mapping) diff --git a/src/plugins/baremetal/baremetalrunconfiguration.cpp b/src/plugins/baremetal/baremetalrunconfiguration.cpp index d75c2d3d914..f021854e6ec 100644 --- a/src/plugins/baremetal/baremetalrunconfiguration.cpp +++ b/src/plugins/baremetal/baremetalrunconfiguration.cpp @@ -30,10 +30,6 @@ public: executable.setDeviceSelector(target, ExecutableAspect::RunDevice); executable.setPlaceHolderText(Tr::tr("Unknown")); - arguments.setMacroExpander(macroExpander()); - - workingDir.setMacroExpander(macroExpander()); - setUpdater([this] { const BuildTargetInfo bti = buildTargetInfo(); executable.setExecutable(bti.targetFilePath); @@ -60,10 +56,6 @@ public: executable.setHistoryCompleter("BareMetal.CustomRunConfig.History"); executable.setExpectedKind(PathChooser::Any); - arguments.setMacroExpander(macroExpander()); - - workingDir.setMacroExpander(macroExpander()); - setDefaultDisplayName(RunConfigurationFactory::decoratedTargetName( Tr::tr("Custom Executable"), target)); setUsesEmptyBuildKeys(); diff --git a/src/plugins/boot2qt/qdbrunconfiguration.cpp b/src/plugins/boot2qt/qdbrunconfiguration.cpp index b2628093a59..6b03c117898 100644 --- a/src/plugins/boot2qt/qdbrunconfiguration.cpp +++ b/src/plugins/boot2qt/qdbrunconfiguration.cpp @@ -47,9 +47,6 @@ public: environment.setDeviceSelector(target, EnvironmentAspect::RunDevice); - arguments.setMacroExpander(macroExpander()); - - workingDir.setMacroExpander(macroExpander()); workingDir.setEnvironment(&environment); fullCommand.setLabelText(Tr::tr("Full command line:")); diff --git a/src/plugins/haskell/haskellrunconfiguration.cpp b/src/plugins/haskell/haskellrunconfiguration.cpp index bdb5a70e161..c2acef8cb49 100644 --- a/src/plugins/haskell/haskellrunconfiguration.cpp +++ b/src/plugins/haskell/haskellrunconfiguration.cpp @@ -37,9 +37,6 @@ public: executable.setSettingsKey("Haskell.Executable"); executable.setLabelText(Tr::tr("Executable")); - arguments.setMacroExpander(macroExpander()); - - workingDir.setMacroExpander(macroExpander()); workingDir.setEnvironment(&environment); workingDir.setDefaultWorkingDirectory(project()->projectDirectory()); workingDir.setVisible(false); diff --git a/src/plugins/ios/iosrunconfiguration.cpp b/src/plugins/ios/iosrunconfiguration.cpp index 9c684df9e60..6fe27834120 100644 --- a/src/plugins/ios/iosrunconfiguration.cpp +++ b/src/plugins/ios/iosrunconfiguration.cpp @@ -64,8 +64,6 @@ IosRunConfiguration::IosRunConfiguration(Target *target, Id id) { executable.setDeviceSelector(target, ExecutableAspect::RunDevice); - arguments.setMacroExpander(macroExpander()); - setUpdater([this, target] { IDevice::ConstPtr dev = DeviceKitAspect::device(target->kit()); const QString devName = dev ? dev->displayName() : IosDevice::name(); diff --git a/src/plugins/mesonprojectmanager/mesonrunconfiguration.cpp b/src/plugins/mesonprojectmanager/mesonrunconfiguration.cpp index 2b5a285a604..65c732f335c 100644 --- a/src/plugins/mesonprojectmanager/mesonrunconfiguration.cpp +++ b/src/plugins/mesonprojectmanager/mesonrunconfiguration.cpp @@ -31,9 +31,6 @@ public: executable.setDeviceSelector(target, ExecutableAspect::RunDevice); - arguments.setMacroExpander(macroExpander()); - - workingDir.setMacroExpander(macroExpander()); workingDir.setEnvironment(&environment); connect(&useLibraryPaths, &BaseAspect::changed, diff --git a/src/plugins/nim/project/nimblebuildstep.cpp b/src/plugins/nim/project/nimblebuildstep.cpp index 0177ce2d1b8..efda9aa5baf 100644 --- a/src/plugins/nim/project/nimblebuildstep.cpp +++ b/src/plugins/nim/project/nimblebuildstep.cpp @@ -24,7 +24,6 @@ public: NimbleBuildStep(BuildStepList *parentList, Id id) : AbstractProcessStep(parentList, id) { - arguments.setMacroExpander(macroExpander()); arguments.setSettingsKey(Constants::C_NIMBLEBUILDSTEP_ARGUMENTS); arguments.setResetter([this] { return defaultArguments(); }); arguments.setArguments(defaultArguments()); diff --git a/src/plugins/nim/project/nimblerunconfiguration.cpp b/src/plugins/nim/project/nimblerunconfiguration.cpp index e23942f8c4f..4e6884e8a0a 100644 --- a/src/plugins/nim/project/nimblerunconfiguration.cpp +++ b/src/plugins/nim/project/nimblerunconfiguration.cpp @@ -28,10 +28,6 @@ public: executable.setDeviceSelector(target, ExecutableAspect::RunDevice); - arguments.setMacroExpander(macroExpander()); - - workingDir.setMacroExpander(macroExpander()); - setUpdater([this] { BuildTargetInfo bti = buildTargetInfo(); setDisplayName(bti.displayName); @@ -74,10 +70,8 @@ public: executable.setDeviceSelector(target, ExecutableAspect::BuildDevice); executable.setExecutable(Nim::nimblePathFromKit(kit())); - arguments.setMacroExpander(macroExpander()); arguments.setArguments("test"); - workingDir.setMacroExpander(macroExpander()); workingDir.setDefaultWorkingDirectory(project()->projectDirectory()); } diff --git a/src/plugins/nim/project/nimrunconfiguration.cpp b/src/plugins/nim/project/nimrunconfiguration.cpp index 30ed5d64d3b..30ed9c998df 100644 --- a/src/plugins/nim/project/nimrunconfiguration.cpp +++ b/src/plugins/nim/project/nimrunconfiguration.cpp @@ -30,10 +30,6 @@ public: executable.setDeviceSelector(target, ExecutableAspect::RunDevice); - arguments.setMacroExpander(macroExpander()); - - workingDir.setMacroExpander(macroExpander()); - setDisplayName(Tr::tr("Current Build Target")); setDefaultDisplayName(Tr::tr("Current Build Target")); diff --git a/src/plugins/projectexplorer/buildconfiguration.cpp b/src/plugins/projectexplorer/buildconfiguration.cpp index 7e6be34f7c3..5ad0891c6b1 100644 --- a/src/plugins/projectexplorer/buildconfiguration.cpp +++ b/src/plugins/projectexplorer/buildconfiguration.cpp @@ -146,7 +146,6 @@ public: bool m_configWidgetHasFrame = false; QList m_initialBuildSteps; QList m_initialCleanSteps; - Utils::MacroExpander m_macroExpander; bool m_parseStdOut = false; QList m_customParsers; @@ -288,11 +287,6 @@ void BuildConfiguration::doInitialize(const BuildInfo &info) d->m_initializer(info); } -MacroExpander *BuildConfiguration::macroExpander() const -{ - return &d->m_macroExpander; -} - bool BuildConfiguration::createBuildDirectory() { const bool result = bool(buildDirectory().ensureWritableDir()); diff --git a/src/plugins/projectexplorer/buildconfiguration.h b/src/plugins/projectexplorer/buildconfiguration.h index 8b765e32fec..f8f42917018 100644 --- a/src/plugins/projectexplorer/buildconfiguration.h +++ b/src/plugins/projectexplorer/buildconfiguration.h @@ -111,8 +111,6 @@ public: void doInitialize(const BuildInfo &info); - Utils::MacroExpander *macroExpander() const; - bool createBuildDirectory(); signals: diff --git a/src/plugins/projectexplorer/buildstep.cpp b/src/plugins/projectexplorer/buildstep.cpp index e614e1f9f18..1b07968338e 100644 --- a/src/plugins/projectexplorer/buildstep.cpp +++ b/src/plugins/projectexplorer/buildstep.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -85,10 +86,8 @@ BuildStep::BuildStep(BuildStepList *bsl, Id id) : ProjectConfiguration(bsl->target(), id) , m_stepList(bsl) { - if (auto bc = buildConfiguration()) - setMacroExpander(bc->macroExpander()); - connect(this, &ProjectConfiguration::displayNameChanged, this, &BuildStep::updateSummary); + macroExpander()->registerSubProvider([bsl] { return bsl->projectConfiguration()->macroExpander(); }); } QWidget *BuildStep::doCreateConfigWidget() diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp index 1ed87420307..b9c746703c5 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp @@ -32,9 +32,6 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *targe executable.setExpectedKind(PathChooser::ExistingCommand); executable.setEnvironment(environment.environment()); - arguments.setMacroExpander(macroExpander()); - - workingDir.setMacroExpander(macroExpander()); workingDir.setEnvironment(&environment); connect(&environment, &EnvironmentAspect::environmentChanged, this, [this] { diff --git a/src/plugins/projectexplorer/desktoprunconfiguration.cpp b/src/plugins/projectexplorer/desktoprunconfiguration.cpp index 02f31c13452..7842e501fd4 100644 --- a/src/plugins/projectexplorer/desktoprunconfiguration.cpp +++ b/src/plugins/projectexplorer/desktoprunconfiguration.cpp @@ -32,9 +32,6 @@ protected: executable.setDeviceSelector(target, ExecutableAspect::RunDevice); - arguments.setMacroExpander(macroExpander()); - - workingDir.setMacroExpander(macroExpander()); workingDir.setEnvironment(&environment); connect(&useLibraryPaths, &UseLibraryPathsAspect::changed, diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 0c920487d90..3315c2cb0f6 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -148,28 +148,27 @@ RunConfiguration::RunConfiguration(Target *target, Utils::Id id) forceDisplayNameSerialization(); connect(target, &Target::parsingFinished, this, &RunConfiguration::update); - setMacroExpander(&m_expander); - - m_expander.setDisplayName(Tr::tr("Run Settings")); - m_expander.setAccumulating(true); - m_expander.registerSubProvider([target] { + MacroExpander &expander = *macroExpander(); + expander.setDisplayName(Tr::tr("Run Settings")); + expander.setAccumulating(true); + expander.registerSubProvider([target] { BuildConfiguration *bc = target->activeBuildConfiguration(); return bc ? bc->macroExpander() : target->macroExpander(); }); - m_expander.registerPrefix("RunConfig:Env", Tr::tr("Variables in the run environment."), + expander.registerPrefix("RunConfig:Env", Tr::tr("Variables in the run environment."), [this](const QString &var) { const auto envAspect = aspect(); return envAspect ? envAspect->environment().expandedValueForKey(var) : QString(); }); - m_expander.registerVariable("RunConfig:WorkingDir", + expander.registerVariable("RunConfig:WorkingDir", Tr::tr("The run configuration's working directory."), [this] { const auto wdAspect = aspect(); return wdAspect ? wdAspect->workingDirectory().toString() : QString(); }); - m_expander.registerVariable("RunConfig:Name", Tr::tr("The run configuration's name."), + expander.registerVariable("RunConfig:Name", Tr::tr("The run configuration's name."), [this] { return displayName(); }); - m_expander.registerFileVariables("RunConfig:Executable", + expander.registerFileVariables("RunConfig:Executable", Tr::tr("The run configuration's executable."), [this] { return commandLine().executable(); }); @@ -222,7 +221,7 @@ QWidget *RunConfiguration::createConfigurationWidget() } auto widget = form.emerge(); - VariableChooser::addSupportForChildWidgets(widget, &m_expander); + VariableChooser::addSupportForChildWidgets(widget, macroExpander()); auto detailsWidget = new Utils::DetailsWidget; detailsWidget->setState(DetailsWidget::NoSummary); diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 84b385330f0..ca78c0ee056 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -203,7 +203,6 @@ private: CommandLineGetter m_commandLineGetter; RunnableModifier m_runnableModifier; Updater m_updater; - Utils::MacroExpander m_expander; Utils::Store m_pristineState; bool m_customized = false; bool m_usesEmptyBuildKeys = false; diff --git a/src/plugins/projectexplorer/runconfigurationaspects.cpp b/src/plugins/projectexplorer/runconfigurationaspects.cpp index a3081663bb5..74d9d2b7b0f 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/runconfigurationaspects.cpp @@ -320,11 +320,6 @@ ArgumentsAspect::ArgumentsAspect(AspectContainer *container) addDataExtractor(this, &ArgumentsAspect::arguments, &Data::arguments); } -void ArgumentsAspect::setMacroExpander(const MacroExpander *expander) -{ - m_macroExpander = expander; -} - /*! Returns the main value of this aspect. @@ -332,12 +327,11 @@ void ArgumentsAspect::setMacroExpander(const MacroExpander *expander) */ QString ArgumentsAspect::arguments() const { - QTC_ASSERT(m_macroExpander, return m_arguments); if (m_currentlyExpanding) return m_arguments; m_currentlyExpanding = true; - const QString expanded = m_macroExpander->expandProcessArgs(m_arguments); + const QString expanded = macroExpander()->expandProcessArgs(m_arguments); m_currentlyExpanding = false; return expanded; } @@ -969,15 +963,9 @@ X11ForwardingAspect::X11ForwardingAspect(AspectContainer *container) addDataExtractor(this, &X11ForwardingAspect::display, &Data::display); } -void X11ForwardingAspect::setMacroExpander(const MacroExpander *expander) -{ - m_macroExpander = expander; -} - QString X11ForwardingAspect::display() const { - QTC_ASSERT(m_macroExpander, return value()); - return !isChecked() ? QString() : m_macroExpander->expandProcessArgs(value()); + return !isChecked() ? QString() : macroExpander()->expandProcessArgs(value()); } diff --git a/src/plugins/projectexplorer/runconfigurationaspects.h b/src/plugins/projectexplorer/runconfigurationaspects.h index 5f5f2f5b45c..3b79d24a675 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.h +++ b/src/plugins/projectexplorer/runconfigurationaspects.h @@ -100,7 +100,6 @@ public: void setArguments(const QString &arguments); void setResetter(const std::function &resetter); void resetArguments(); - void setMacroExpander(const Utils::MacroExpander *macroExpander); struct Data : BaseAspect::Data { @@ -121,7 +120,6 @@ private: bool m_multiLine = false; mutable bool m_currentlyExpanding = false; std::function m_resetter; - const Utils::MacroExpander *m_macroExpander = nullptr; }; class PROJECTEXPLORER_EXPORT UseLibraryPathsAspect : public Utils::BoolAspect @@ -268,14 +266,9 @@ class PROJECTEXPLORER_EXPORT X11ForwardingAspect : public Utils::StringAspect public: X11ForwardingAspect(Utils::AspectContainer *container = nullptr); - void setMacroExpander(const Utils::MacroExpander *macroExpander); - struct Data : StringAspect::Data { QString display; }; QString display() const; - -private: - const Utils::MacroExpander *m_macroExpander; }; } // namespace ProjectExplorer diff --git a/src/plugins/python/pythonrunconfiguration.cpp b/src/plugins/python/pythonrunconfiguration.cpp index e4ec5a9e845..e8f6719a0ab 100644 --- a/src/plugins/python/pythonrunconfiguration.cpp +++ b/src/plugins/python/pythonrunconfiguration.cpp @@ -119,11 +119,6 @@ public: environment.setSupportForBuildEnvironment(target); - arguments.setMacroExpander(macroExpander()); - - workingDir.setMacroExpander(macroExpander()); - - x11Forwarding.setMacroExpander(macroExpander()); x11Forwarding.setVisible(HostOsInfo::isAnyUnixHost()); interpreter.setLabelText(Tr::tr("Python:")); diff --git a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp index e56611f7e15..89a3e562889 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp +++ b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp @@ -518,9 +518,9 @@ QbsBuildStepConfigWidget::QbsBuildStepConfigWidget(QbsBuildStep *step) defaultInstallDirCheckBox->setText(QbsProjectManager::Tr::tr("Use default location")); auto chooser = new VariableChooser(this); + chooser->addMacroExpanderProvider([this] { return m_qbsStep->macroExpander(); }); chooser->addSupportedWidget(propertyEdit); chooser->addSupportedWidget(installDirChooser->lineEdit()); - chooser->addMacroExpanderProvider([step] { return step->macroExpander(); }); propertyEdit->setValidationFunction([this](FancyLineEdit *edit, QString *errorMessage) { return validateProperties(edit, errorMessage); }); diff --git a/src/plugins/qmakeprojectmanager/qmakestep.cpp b/src/plugins/qmakeprojectmanager/qmakestep.cpp index f009274dcb2..179e1796728 100644 --- a/src/plugins/qmakeprojectmanager/qmakestep.cpp +++ b/src/plugins/qmakeprojectmanager/qmakestep.cpp @@ -69,7 +69,6 @@ QMakeStep::QMakeStep(BuildStepList *bsl, Id id) buildType.addOption(Tr::tr("Debug")); buildType.addOption(Tr::tr("Release")); - userArguments.setMacroExpander(macroExpander()); userArguments.setSettingsKey(QMAKE_ARGUMENTS_KEY); userArguments.setLabelText(Tr::tr("Additional arguments:")); diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index d5debe0211c..25ff5522bca 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -84,7 +84,6 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id) qmlViewer.setHistoryCompleter("QmlProjectManager.viewer.history"); arguments.setSettingsKey(Constants::QML_VIEWER_ARGUMENTS_KEY); - arguments.setMacroExpander(macroExpander()); setCommandLineGetter([this, target] { const FilePath qmlRuntime = qmlRuntimeFilePath(); @@ -169,8 +168,6 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id) return envModifier(environment); }); - x11Forwarding.setMacroExpander(macroExpander()); - setRunnableModifier([this](ProcessRunData &r) { const QmlBuildSystem *bs = static_cast(activeBuildSystem()); r.workingDirectory = bs->targetDirectory(); diff --git a/src/plugins/qnx/qnxrunconfiguration.cpp b/src/plugins/qnx/qnxrunconfiguration.cpp index 9f00bb8b5a0..37092106346 100644 --- a/src/plugins/qnx/qnxrunconfiguration.cpp +++ b/src/plugins/qnx/qnxrunconfiguration.cpp @@ -42,9 +42,6 @@ public: environment.setDeviceSelector(target, EnvironmentAspect::RunDevice); - arguments.setMacroExpander(macroExpander()); - - workingDir.setMacroExpander(macroExpander()); workingDir.setEnvironment(&environment); qtLibraries.setSettingsKey("Qt4ProjectManager.QnxRunConfiguration.QtLibPath"); diff --git a/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp b/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp index 74032bc15ed..5200e59b330 100644 --- a/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp +++ b/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp @@ -51,15 +51,10 @@ RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *tar symbolFile.setSettingsKey("RemoteLinux.CustomRunConfig.LocalExecutable"); symbolFile.setLabelText(Tr::tr("Local executable:")); - arguments.setMacroExpander(macroExpander()); - - workingDir.setMacroExpander(macroExpander()); workingDir.setEnvironment(&environment); terminal.setVisible(HostOsInfo::isAnyUnixHost()); - x11Forwarding.setMacroExpander(macroExpander()); - setDefaultDisplayName(runConfigDefaultDisplayName()); setUsesEmptyBuildKeys(); } diff --git a/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp b/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp index 4ad48fac8d5..7700c42d3e5 100644 --- a/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp +++ b/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp @@ -52,15 +52,10 @@ RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id) symbolFile.setLabelText(Tr::tr("Executable on host:")); - arguments.setMacroExpander(macroExpander()); - - workingDir.setMacroExpander(macroExpander()); workingDir.setEnvironment(&environment); terminal.setVisible(HostOsInfo::isAnyUnixHost()); - x11Forwarding.setMacroExpander(macroExpander()); - connect(&useLibraryPath, &BaseAspect::changed, &environment, &EnvironmentAspect::environmentChanged);