aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2019-06-11 14:39:39 +0200
committerhjk <hjk@qt.io>2019-06-12 12:30:23 +0000
commit7ebe005206327d458e8b414b8ccdee1f02a51da6 (patch)
tree3e3a29365529fdd5184678fdf879f081fcd50f74 /src/plugins
parenta51b8a061e91ed615bd48b348dcc133e01f49dbf (diff)
ProjectExplorer: Replace RunConfiguration::executable
... by a RunConfiguration::commandLine(). That's what is typically consumed, and removes the need for some custom runnable() implementations. Change-Id: I7700b12cdd0965802a0add977b432314734a5a72 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/projectexplorer/customexecutablerunconfiguration.cpp3
-rw-r--r--src/plugins/projectexplorer/projectexplorer.cpp2
-rw-r--r--src/plugins/projectexplorer/runconfiguration.cpp22
-rw-r--r--src/plugins/projectexplorer/runconfiguration.h8
-rw-r--r--src/plugins/projectexplorer/runconfigurationaspects.cpp8
-rw-r--r--src/plugins/projectexplorer/runconfigurationaspects.h1
-rw-r--r--src/plugins/pythoneditor/pythoneditorplugin.cpp22
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp19
8 files changed, 44 insertions, 41 deletions
diff --git a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp
index 957b7424744..6804ffb95d2 100644
--- a/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp
+++ b/src/plugins/projectexplorer/customexecutablerunconfiguration.cpp
@@ -255,8 +255,7 @@ Runnable CustomExecutableRunConfiguration::runnable() const
aspect<WorkingDirectoryAspect>()->workingDirectory(macroExpander());
Runnable r;
- r.executable = executable().toString();
- r.commandLineArguments = aspect<ArgumentsAspect>()->arguments(macroExpander());
+ r.setCommandLine(commandLine());
r.environment = aspect<EnvironmentAspect>()->environment();
r.workingDirectory = workingDirectory.toString();
r.device = DeviceManager::instance()->defaultDevice(Constants::DESKTOP_DEVICE_TYPE);
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index 82a8ff8ed3a..ad485a38c31 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -1640,7 +1640,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
[]() -> QString {
if (Target *target = activeTarget()) {
if (RunConfiguration *rc = target->activeRunConfiguration())
- return rc->executable().toString();
+ return rc->commandLine().executable().toString();
}
return QString();
});
diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp
index 5c3c6fc0e9c..72697aa9a15 100644
--- a/src/plugins/projectexplorer/runconfiguration.cpp
+++ b/src/plugins/projectexplorer/runconfiguration.cpp
@@ -201,10 +201,14 @@ RunConfiguration::RunConfiguration(Target *target, Core::Id id)
for (const AspectFactory &factory : theAspectFactories)
m_aspects.append(factory(target));
- m_executableGetter = [this] {
+ m_commandLineGetter = [this] {
+ FilePath executable;
if (const auto executableAspect = aspect<ExecutableAspect>())
- return executableAspect->executable();
- return FilePath();
+ executable = executableAspect->executable();
+ QString arguments;
+ if (const auto argumentsAspect = aspect<ArgumentsAspect>())
+ arguments = argumentsAspect->arguments(macroExpander());
+ return CommandLine{executable, arguments, CommandLine::Raw};
};
}
@@ -327,14 +331,14 @@ QVariantMap RunConfiguration::toMap() const
return map;
}
-void RunConfiguration::setExecutableGetter(const RunConfiguration::ExecutableGetter &exeGetter)
+void RunConfiguration::setCommandLineGetter(const CommandLineGetter &cmdGetter)
{
- m_executableGetter = exeGetter;
+ m_commandLineGetter = cmdGetter;
}
-FilePath RunConfiguration::executable() const
+CommandLine RunConfiguration::commandLine() const
{
- return m_executableGetter();
+ return m_commandLineGetter();
}
BuildTargetInfo RunConfiguration::buildTargetInfo() const
@@ -392,9 +396,7 @@ bool RunConfiguration::fromMap(const QVariantMap &map)
Runnable RunConfiguration::runnable() const
{
Runnable r;
- r.executable = executable().toString();
- if (auto argumentsAspect = aspect<ArgumentsAspect>())
- r.commandLineArguments = argumentsAspect->arguments(macroExpander());
+ r.setCommandLine(commandLine());
if (auto workingDirectoryAspect = aspect<WorkingDirectoryAspect>())
r.workingDirectory = workingDirectoryAspect->workingDirectory(macroExpander()).toString();
if (auto environmentAspect = aspect<EnvironmentAspect>())
diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h
index 3e5cbc6b157..3e9dd61e01e 100644
--- a/src/plugins/projectexplorer/runconfiguration.h
+++ b/src/plugins/projectexplorer/runconfiguration.h
@@ -160,9 +160,9 @@ public:
bool fromMap(const QVariantMap &map) override;
QVariantMap toMap() const override;
- using ExecutableGetter = std::function<Utils::FilePath()>;
- void setExecutableGetter(const ExecutableGetter &exeGetter);
- Utils::FilePath executable() const;
+ using CommandLineGetter = std::function<Utils::CommandLine()>;
+ void setCommandLineGetter(const CommandLineGetter &cmdGetter);
+ Utils::CommandLine commandLine() const;
virtual Runnable runnable() const;
@@ -214,7 +214,7 @@ private:
QString m_buildKey;
bool m_isEnabled = false;
std::function<Utils::OutputFormatter *(Project *)> m_outputFormatterCreator;
- ExecutableGetter m_executableGetter;
+ CommandLineGetter m_commandLineGetter;
};
class RunConfigurationCreationInfo
diff --git a/src/plugins/projectexplorer/runconfigurationaspects.cpp b/src/plugins/projectexplorer/runconfigurationaspects.cpp
index fe890b3a294..38b080c370b 100644
--- a/src/plugins/projectexplorer/runconfigurationaspects.cpp
+++ b/src/plugins/projectexplorer/runconfigurationaspects.cpp
@@ -264,7 +264,13 @@ ArgumentsAspect::ArgumentsAspect()
QString ArgumentsAspect::arguments(const MacroExpander *expander) const
{
QTC_ASSERT(expander, return m_arguments);
- return expander->expandProcessArgs(m_arguments);
+ if (m_currentlyExpanding)
+ return m_arguments;
+
+ m_currentlyExpanding = true;
+ const QString expanded = expander->expandProcessArgs(m_arguments);
+ m_currentlyExpanding = false;
+ return expanded;
}
QString ArgumentsAspect::unexpandedArguments() const
diff --git a/src/plugins/projectexplorer/runconfigurationaspects.h b/src/plugins/projectexplorer/runconfigurationaspects.h
index 77973f65f43..78a4e5b965f 100644
--- a/src/plugins/projectexplorer/runconfigurationaspects.h
+++ b/src/plugins/projectexplorer/runconfigurationaspects.h
@@ -115,6 +115,7 @@ private:
QString m_arguments;
QPointer<Utils::FancyLineEdit> m_chooser;
+ mutable bool m_currentlyExpanding = false;
};
class PROJECTEXPLORER_EXPORT UseLibraryPathsAspect : public BaseBoolAspect
diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp
index 9a494b47b08..8dd87ebbdab 100644
--- a/src/plugins/pythoneditor/pythoneditorplugin.cpp
+++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp
@@ -246,7 +246,6 @@ public:
private:
void doAdditionalSetup(const RunConfigurationCreationInfo &) final { updateTargetInformation(); }
- Runnable runnable() const final;
bool supportsDebugger() const { return true; }
QString mainScript() const { return aspect<MainScriptAspect>()->value(); }
@@ -275,12 +274,16 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Core::Id id)
scriptAspect->setDisplayStyle(BaseStringAspect::LabelDisplay);
addAspect<LocalEnvironmentAspect>(target);
- addAspect<ArgumentsAspect>();
+
+ auto argumentsAspect = addAspect<ArgumentsAspect>();
+
addAspect<TerminalAspect>();
setOutputFormatter<PythonOutputFormatter>();
- setExecutableGetter([this] {
- return FilePath::fromString(aspect<InterpreterAspect>()->value());
+ setCommandLineGetter([this, interpreterAspect, argumentsAspect] {
+ CommandLine cmd{FilePath::fromString(interpreterAspect->value()), {mainScript()}};
+ cmd.addArgs(argumentsAspect->arguments(macroExpander()), CommandLine::Raw);
+ return cmd;
});
connect(target, &Target::applicationTargetsChanged,
@@ -297,17 +300,6 @@ void PythonRunConfiguration::updateTargetInformation()
aspect<MainScriptAspect>()->setValue(script);
}
-Runnable PythonRunConfiguration::runnable() const
-{
- CommandLine cmd{executable(), {mainScript()}};
- cmd.addArgs(aspect<ArgumentsAspect>()->arguments(macroExpander()), CommandLine::Raw);
-
- Runnable r;
- r.setCommandLine(cmd);
- r.environment = aspect<EnvironmentAspect>()->environment();
- return r;
-}
-
class PythonRunConfigurationFactory : public RunConfigurationFactory
{
public:
diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp
index f2e54f6444a..cd7d04ce84a 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp
+++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp
@@ -298,17 +298,21 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id)
return envModifier(Environment());
});
- setExecutableGetter([this] { return FilePath::fromString(theExecutable()); });
-
m_qmlViewerAspect = addAspect<BaseStringAspect>();
m_qmlViewerAspect->setLabelText(tr("QML Viewer:"));
- m_qmlViewerAspect->setPlaceHolderText(executable().toString());
+ m_qmlViewerAspect->setPlaceHolderText(commandLine().executable().toString());
m_qmlViewerAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay);
m_qmlViewerAspect->setHistoryCompleter("QmlProjectManager.viewer.history");
auto argumentAspect = addAspect<ArgumentsAspect>();
argumentAspect->setSettingsKey(Constants::QML_VIEWER_ARGUMENTS_KEY);
+ setCommandLineGetter([this] {
+ return CommandLine(FilePath::fromString(theExecutable()),
+ commandLineArguments(),
+ CommandLine::Raw);
+ });
+
auto qmlProject = qobject_cast<QmlProject *>(target->project());
QTC_ASSERT(qmlProject, return);
m_mainQmlFileAspect = addAspect<MainQmlFileAspect>(qmlProject);
@@ -326,8 +330,7 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Target *target, Id id)
Runnable QmlProjectRunConfiguration::runnable() const
{
Runnable r;
- r.executable = executable().toString();
- r.commandLineArguments = commandLineArguments();
+ r.setCommandLine(commandLine());
r.environment = aspect<EnvironmentAspect>()->environment();
r.workingDirectory = static_cast<QmlProject *>(project())->targetDirectory(target()).toString();
return r;
@@ -339,10 +342,10 @@ QString QmlProjectRunConfiguration::disabledReason() const
return tr("No script file to execute.");
if (DeviceTypeKitAspect::deviceTypeId(target()->kit())
== ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE
- && !executable().exists()) {
+ && !commandLine().executable().exists()) {
return tr("No qmlscene found.");
}
- if (executable().isEmpty())
+ if (commandLine().executable().isEmpty())
return tr("No qmlscene binary specified for target device.");
return RunConfiguration::disabledReason();
}
@@ -405,7 +408,7 @@ QString QmlProjectRunConfiguration::commandLineArguments() const
void QmlProjectRunConfiguration::updateEnabledState()
{
bool enabled = false;
- if (m_mainQmlFileAspect->isQmlFilePresent() && !executable().isEmpty()) {
+ if (m_mainQmlFileAspect->isQmlFilePresent() && !commandLine().executable().isEmpty()) {
Project *p = target()->project();
enabled = !p->isParsing() && p->hasParsingData();
}