diff --git a/src/plugins/android/androidrunconfiguration.cpp b/src/plugins/android/androidrunconfiguration.cpp index 9948f69b5d7..17cefd1d89f 100644 --- a/src/plugins/android/androidrunconfiguration.cpp +++ b/src/plugins/android/androidrunconfiguration.cpp @@ -111,28 +111,25 @@ void BaseStringListAspect::setLabel(const QString &label) AndroidRunConfiguration::AndroidRunConfiguration(Target *target, Core::Id id) : RunConfiguration(target, id) { - addExtraAspect(new AndroidRunEnvironmentAspect(this)); - addExtraAspect(new ArgumentsAspect(this)); + addAspect(); + addAspect(); - auto amStartArgsAspect = new BaseStringAspect(this); + auto amStartArgsAspect = addAspect(); amStartArgsAspect->setId(Constants::ANDROID_AMSTARTARGS); amStartArgsAspect->setSettingsKey("Android.AmStartArgsKey"); amStartArgsAspect->setLabelText(tr("Activity manager start options:")); amStartArgsAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay); amStartArgsAspect->setHistoryCompleter("Android.AmStartArgs.History"); - addExtraAspect(amStartArgsAspect); - auto preStartShellCmdAspect = new BaseStringListAspect(this); + auto preStartShellCmdAspect = addAspect(); preStartShellCmdAspect->setId(Constants::ANDROID_PRESTARTSHELLCMDLIST); preStartShellCmdAspect->setSettingsKey("Android.PreStartShellCmdListKey"); preStartShellCmdAspect->setLabel(tr("Shell commands to run on Android device before application launch.")); - addExtraAspect(preStartShellCmdAspect); - auto postStartShellCmdAspect = new BaseStringListAspect(this); + auto postStartShellCmdAspect = addAspect(); postStartShellCmdAspect->setId(Constants::ANDROID_POSTFINISHSHELLCMDLIST); postStartShellCmdAspect->setSettingsKey("Android.PostStartShellCmdListKey"); postStartShellCmdAspect->setLabel(tr("Shell commands to run on Android device after application quits.")); - addExtraAspect(postStartShellCmdAspect); setOutputFormatter(); connect(target->project(), &Project::parsingFinished, this, [this] { diff --git a/src/plugins/baremetal/baremetalcustomrunconfiguration.cpp b/src/plugins/baremetal/baremetalcustomrunconfiguration.cpp index c184d39bfba..29495ee472b 100644 --- a/src/plugins/baremetal/baremetalcustomrunconfiguration.cpp +++ b/src/plugins/baremetal/baremetalcustomrunconfiguration.cpp @@ -41,16 +41,15 @@ namespace Internal { BareMetalCustomRunConfiguration::BareMetalCustomRunConfiguration(Target *target, Core::Id id) : RunConfiguration(target, id) { - auto exeAspect = new ExecutableAspect(this); + auto exeAspect = addAspect(); exeAspect->setSettingsKey("BareMetal.CustomRunConfig.Executable"); exeAspect->setPlaceHolderText(tr("Unknown")); exeAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay); exeAspect->setHistoryCompleter("BareMetal.CustomRunConfig.History"); exeAspect->setExpectedKind(PathChooser::Any); - addExtraAspect(exeAspect); - addExtraAspect(new ArgumentsAspect(this)); - addExtraAspect(new WorkingDirectoryAspect(this)); + addAspect(); + addAspect(); setDefaultDisplayName(RunConfigurationFactory::decoratedTargetName(tr("Custom Executable"), target)); } diff --git a/src/plugins/baremetal/baremetalrunconfiguration.cpp b/src/plugins/baremetal/baremetalrunconfiguration.cpp index 6698fc7bbc6..8cb2aa3a8c4 100644 --- a/src/plugins/baremetal/baremetalrunconfiguration.cpp +++ b/src/plugins/baremetal/baremetalrunconfiguration.cpp @@ -43,13 +43,12 @@ namespace Internal { BareMetalRunConfiguration::BareMetalRunConfiguration(Target *target, Core::Id id) : RunConfiguration(target, id) { - auto exeAspect = new ExecutableAspect(this); + auto exeAspect = addAspect(); exeAspect->setDisplayStyle(BaseStringAspect::LabelDisplay); exeAspect->setPlaceHolderText(tr("Unknown")); - addExtraAspect(exeAspect); - addExtraAspect(new ArgumentsAspect(this)); - addExtraAspect(new WorkingDirectoryAspect(this)); + addAspect(); + addAspect(); connect(target, &Target::deploymentDataChanged, this, &BareMetalRunConfiguration::updateTargetInformation); diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp index 30945013a9a..f27c6156a95 100644 --- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp @@ -53,11 +53,11 @@ CMakeRunConfiguration::CMakeRunConfiguration(Target *target, Core::Id id) if (qt) env.prependOrSetPath(qt->qmakeProperty("QT_INSTALL_BINS")); }; - addExtraAspect(new LocalEnvironmentAspect(this, cmakeRunEnvironmentModifier)); - addExtraAspect(new ExecutableAspect(this)); - addExtraAspect(new ArgumentsAspect(this)); - addExtraAspect(new WorkingDirectoryAspect(this)); - addExtraAspect(new TerminalAspect(this)); + addAspect(cmakeRunEnvironmentModifier); + addAspect(); + addAspect(); + addAspect(); + addAspect(); connect(target->project(), &Project::parsingFinished, this, &CMakeRunConfiguration::updateTargetInformation); diff --git a/src/plugins/ios/iosrunconfiguration.cpp b/src/plugins/ios/iosrunconfiguration.cpp index 6f0d53684e4..0512286d355 100644 --- a/src/plugins/ios/iosrunconfiguration.cpp +++ b/src/plugins/ios/iosrunconfiguration.cpp @@ -97,7 +97,7 @@ private: IosRunConfiguration::IosRunConfiguration(Target *target, Core::Id id) : RunConfiguration(target, id) { - addExtraAspect(new ArgumentsAspect(this)); + addAspect(); setOutputFormatter(); connect(DeviceManager::instance(), &DeviceManager::updated, diff --git a/src/plugins/nim/project/nimrunconfiguration.cpp b/src/plugins/nim/project/nimrunconfiguration.cpp index 3a3704322d0..216b277126a 100644 --- a/src/plugins/nim/project/nimrunconfiguration.cpp +++ b/src/plugins/nim/project/nimrunconfiguration.cpp @@ -44,11 +44,11 @@ namespace Nim { NimRunConfiguration::NimRunConfiguration(Target *target, Core::Id id) : RunConfiguration(target, id) { - addExtraAspect(new ExecutableAspect(this)); - addExtraAspect(new ArgumentsAspect(this)); - addExtraAspect(new WorkingDirectoryAspect(this)); - addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier())); - addExtraAspect(new TerminalAspect(this)); + addAspect(); + addAspect(); + addAspect(); + addAspect(LocalEnvironmentAspect::BaseEnvironmentModifier()); + addAspect(); setDisplayName(tr("Current Build Target")); setDefaultDisplayName(tr("Current Build Target")); diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp index 42393a23db6..708e25477c1 100644 --- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp +++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp @@ -175,20 +175,18 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *targe CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *target, Core::Id id) : RunConfiguration(target, id) { - auto envAspect = new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier()); - addExtraAspect(envAspect); + auto envAspect = addAspect(LocalEnvironmentAspect::BaseEnvironmentModifier()); - auto exeAspect = new ExecutableAspect(this); + auto exeAspect = addAspect(); exeAspect->setSettingsKey("ProjectExplorer.CustomExecutableRunConfiguration.Executable"); exeAspect->setDisplayStyle(BaseStringAspect::PathChooserDisplay); exeAspect->setHistoryCompleter("Qt.CustomExecutable.History"); exeAspect->setExpectedKind(PathChooser::ExistingCommand); exeAspect->setEnvironment(envAspect->environment()); - addExtraAspect(exeAspect); - addExtraAspect(new ArgumentsAspect(this)); - addExtraAspect(new WorkingDirectoryAspect(this)); - addExtraAspect(new TerminalAspect(this)); + addAspect(); + addAspect(); + addAspect(); connect(envAspect, &EnvironmentAspect::environmentChanged, this, [exeAspect, envAspect] { exeAspect->setEnvironment(envAspect->environment()); }); diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 595aa2a024f..80db4d1189e 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -231,7 +231,7 @@ RunConfiguration::RunConfiguration(Target *target, Core::Id id) [this] { return displayName(); }, false); for (const AspectFactory &factory : theAspectFactories) - addExtraAspect(factory(this)); + m_aspects.append(factory(this)); } RunConfiguration::~RunConfiguration() @@ -280,12 +280,6 @@ void RunConfiguration::addAspectFactory(const AspectFactory &aspectFactory) theAspectFactories.push_back(aspectFactory); } -void RunConfiguration::addExtraAspect(IRunConfigurationAspect *aspect) -{ - if (aspect) - m_aspects += aspect; -} - /*! * Returns the RunConfiguration of the currently active target * of the startup project, if such exists, or \c nullptr otherwise. diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 47cc11ce483..0277abdd227 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -222,7 +222,13 @@ public: // The BuildTargetInfo corresponding to the buildKey. BuildTargetInfo buildTargetInfo() const; - void addExtraAspect(IRunConfigurationAspect *aspect); + template + Aspect *addAspect(Args && ...args) + { + auto aspect = new Aspect(this, args...); + m_aspects.append(aspect); + return aspect; + } static RunConfiguration *startupRunConfiguration(); virtual bool canRunForNode(const ProjectExplorer::Node *) const { return false; } diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp index 2417c3e7b6d..e64eebd98bf 100644 --- a/src/plugins/pythoneditor/pythoneditorplugin.cpp +++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp @@ -250,23 +250,21 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Core::Id id) const Environment sysEnv = Environment::systemEnvironment(); const QString exec = sysEnv.searchInPath("python").toString(); - auto interpreterAspect = new InterpreterAspect(this); + auto interpreterAspect = addAspect(); interpreterAspect->setSettingsKey("PythonEditor.RunConfiguation.Interpreter"); interpreterAspect->setLabelText(tr("Interpreter:")); interpreterAspect->setDisplayStyle(BaseStringAspect::PathChooserDisplay); interpreterAspect->setHistoryCompleter("PythonEditor.Interpreter.History"); interpreterAspect->setValue(exec.isEmpty() ? "python" : exec); - addExtraAspect(interpreterAspect); - auto scriptAspect = new MainScriptAspect(this); + auto scriptAspect = addAspect(); scriptAspect->setSettingsKey("PythonEditor.RunConfiguation.Script"); scriptAspect->setLabelText(tr("Script:")); scriptAspect->setDisplayStyle(BaseStringAspect::LabelDisplay); - addExtraAspect(scriptAspect); - addExtraAspect(new LocalEnvironmentAspect(this, LocalEnvironmentAspect::BaseEnvironmentModifier())); - addExtraAspect(new ArgumentsAspect(this)); - addExtraAspect(new TerminalAspect(this)); + addAspect(LocalEnvironmentAspect::BaseEnvironmentModifier()); + addAspect(); + addAspect(); setOutputFormatter(); diff --git a/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp b/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp index beac4f3cdd0..ce09c16d781 100644 --- a/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp +++ b/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp @@ -52,26 +52,23 @@ namespace Internal { QbsRunConfiguration::QbsRunConfiguration(Target *target, Core::Id id) : RunConfiguration(target, id) { - auto envAspect = new LocalEnvironmentAspect(this, + auto envAspect = addAspect( [](RunConfiguration *rc, Environment &env) { static_cast(rc)->addToBaseEnvironment(env); }); - addExtraAspect(envAspect); - addExtraAspect(new ExecutableAspect(this)); - addExtraAspect(new ArgumentsAspect(this)); - addExtraAspect(new WorkingDirectoryAspect(this)); - addExtraAspect(new TerminalAspect(this)); + addAspect(); + addAspect(); + addAspect(); + addAspect(); setOutputFormatter(); - auto libAspect = new UseLibraryPathsAspect(this); - addExtraAspect(libAspect); + auto libAspect = addAspect(); connect(libAspect, &UseLibraryPathsAspect::changed, envAspect, &EnvironmentAspect::environmentChanged); if (HostOsInfo::isMacHost()) { - auto dyldAspect = new UseDyldSuffixAspect(this); - addExtraAspect(dyldAspect); + auto dyldAspect = addAspect(); connect(dyldAspect, &UseDyldSuffixAspect::changed, envAspect, &EnvironmentAspect::environmentChanged); } diff --git a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp index 104425d8d28..6ee9d5e4baf 100644 --- a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp +++ b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp @@ -63,26 +63,23 @@ const char PRO_FILE_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.ProFile"; DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *target, Core::Id id) : RunConfiguration(target, id) { - auto envAspect = new LocalEnvironmentAspect(this, [](RunConfiguration *rc, Environment &env) { + auto envAspect = addAspect([](RunConfiguration *rc, Environment &env) { static_cast(rc)->addToBaseEnvironment(env); }); - addExtraAspect(envAspect); - addExtraAspect(new ExecutableAspect(this)); - addExtraAspect(new ArgumentsAspect(this)); - addExtraAspect(new WorkingDirectoryAspect(this)); - addExtraAspect(new TerminalAspect(this)); + addAspect(); + addAspect(); + addAspect(); + addAspect(); setOutputFormatter(); - auto libAspect = new UseLibraryPathsAspect(this); - addExtraAspect(libAspect); + auto libAspect = addAspect(); connect(libAspect, &UseLibraryPathsAspect::changed, envAspect, &EnvironmentAspect::environmentChanged); if (HostOsInfo::isMacHost()) { - auto dyldAspect = new UseDyldSuffixAspect(this); - addExtraAspect(dyldAspect); + auto dyldAspect = addAspect(); connect(dyldAspect, &UseLibraryPathsAspect::changed, envAspect, &EnvironmentAspect::environmentChanged); } diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index 0fd9f17f959..057bb813714 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -55,7 +55,7 @@ const char M_CURRENT_FILE[] = "CurrentFile"; QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id) : RunConfiguration(target, id) { - addExtraAspect(new QmlProjectEnvironmentAspect(this)); + addAspect(); setOutputFormatter(); // reset default settings in constructor diff --git a/src/plugins/qnx/qnxrunconfiguration.cpp b/src/plugins/qnx/qnxrunconfiguration.cpp index 8b546c60923..2825ec3ac0a 100644 --- a/src/plugins/qnx/qnxrunconfiguration.cpp +++ b/src/plugins/qnx/qnxrunconfiguration.cpp @@ -36,10 +36,9 @@ namespace Internal { QnxRunConfiguration::QnxRunConfiguration(Target *target, Core::Id id) : RemoteLinuxRunConfiguration(target, id) { - auto libAspect = new QtLibPathAspect(this); + auto libAspect = addAspect(); libAspect->setSettingsKey("Qt4ProjectManager.QnxRunConfiguration.QtLibPath"); libAspect->setLabelText(tr("Path to Qt libraries on device")); - addExtraAspect(libAspect); } Runnable QnxRunConfiguration::runnable() const diff --git a/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp b/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp index 69776d8f7e3..232b6e97024 100644 --- a/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp +++ b/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp @@ -42,24 +42,22 @@ namespace Internal { RemoteLinuxCustomRunConfiguration::RemoteLinuxCustomRunConfiguration(Target *target, Core::Id id) : RunConfiguration(target, id) { - auto exeAspect = new ExecutableAspect(this); + auto exeAspect = addAspect(); exeAspect->setSettingsKey("RemoteLinux.CustomRunConfig.RemoteExecutable"); exeAspect->setLabelText(tr("Remote executable:")); exeAspect->setExecutablePathStyle(OsTypeLinux); exeAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay); exeAspect->setHistoryCompleter("RemoteLinux.CustomExecutable.History"); exeAspect->setExpectedKind(PathChooser::Any); - addExtraAspect(exeAspect); - auto symbolsAspect = new SymbolFileAspect(this); + auto symbolsAspect = addAspect(); symbolsAspect->setSettingsKey("RemoteLinux.CustomRunConfig.LocalExecutable"); symbolsAspect->setLabelText(tr("Local executable:")); symbolsAspect->setDisplayStyle(SymbolFileAspect::PathChooserDisplay); - addExtraAspect(symbolsAspect); - addExtraAspect(new ArgumentsAspect(this)); - addExtraAspect(new WorkingDirectoryAspect(this)); - addExtraAspect(new RemoteLinuxEnvironmentAspect(this)); + addAspect(); + addAspect(); + addAspect(); setDefaultDisplayName(runConfigDefaultDisplayName()); setOutputFormatter(); diff --git a/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp b/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp index d5f3681a0cc..b03d7dff3b5 100644 --- a/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp +++ b/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp @@ -45,23 +45,21 @@ namespace RemoteLinux { RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Core::Id id) : RunConfiguration(target, id) { - auto exeAspect = new ExecutableAspect(this); + auto exeAspect = addAspect(); exeAspect->setLabelText(tr("Executable on device:")); exeAspect->setExecutablePathStyle(OsTypeLinux); exeAspect->setPlaceHolderText(tr("Remote path not set")); exeAspect->makeOverridable("RemoteLinux.RunConfig.AlternateRemoteExecutable", "RemoteLinux.RunConfig.UseAlternateRemoteExecutable"); exeAspect->setHistoryCompleter("RemoteLinux.AlternateExecutable.History"); - addExtraAspect(exeAspect); - auto symbolsAspect = new SymbolFileAspect(this); + auto symbolsAspect = addAspect(); symbolsAspect->setLabelText(tr("Executable on host:")); symbolsAspect->setDisplayStyle(SymbolFileAspect::LabelDisplay); - addExtraAspect(symbolsAspect); - addExtraAspect(new ArgumentsAspect(this)); - addExtraAspect(new WorkingDirectoryAspect(this)); - addExtraAspect(new RemoteLinuxEnvironmentAspect(this)); + addAspect(); + addAspect(); + addAspect(); setOutputFormatter(); diff --git a/src/plugins/winrt/winrtrunconfiguration.cpp b/src/plugins/winrt/winrtrunconfiguration.cpp index ea7b458d6a9..7a0c5b2525a 100644 --- a/src/plugins/winrt/winrtrunconfiguration.cpp +++ b/src/plugins/winrt/winrtrunconfiguration.cpp @@ -56,8 +56,8 @@ WinRtRunConfiguration::WinRtRunConfiguration(Target *target, Core::Id id) : RunConfiguration(target, id) { setDisplayName(tr("Run App Package")); - addExtraAspect(new ArgumentsAspect(this)); - addExtraAspect(new UninstallAfterStopAspect(this)); + addAspect(); + addAspect(); } QWidget *WinRtRunConfiguration::createConfigurationWidget()