diff --git a/src/plugins/debugger/analyzer/startremotedialog.cpp b/src/plugins/debugger/analyzer/startremotedialog.cpp index 700b688fad8..9f96ab89a2a 100644 --- a/src/plugins/debugger/analyzer/startremotedialog.cpp +++ b/src/plugins/debugger/analyzer/startremotedialog.cpp @@ -129,15 +129,16 @@ void StartRemoteDialog::validate() d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid); } -Runnable StartRemoteDialog::runnable() const +CommandLine StartRemoteDialog::commandLine() const { const Kit *kit = d->kitChooser->currentKit(); const FilePath filePath = DeviceKitAspect::deviceFilePath(kit, d->executable->text()); + return {filePath, d->arguments->text(), CommandLine::Raw}; +} - Runnable r; - r.command = {filePath, d->arguments->text(), CommandLine::Raw}; - r.workingDirectory = FilePath::fromString(d->workingDirectory->text()); - return r; +FilePath StartRemoteDialog::workingDirectory() const +{ + return FilePath::fromString(d->workingDirectory->text()); } } // namespace Debugger diff --git a/src/plugins/debugger/analyzer/startremotedialog.h b/src/plugins/debugger/analyzer/startremotedialog.h index b1b91bc62fd..72d7478fb7d 100644 --- a/src/plugins/debugger/analyzer/startremotedialog.h +++ b/src/plugins/debugger/analyzer/startremotedialog.h @@ -29,7 +29,10 @@ #include -namespace ProjectExplorer { class Runnable; } +namespace Utils { +class CommandLine; +class FilePath; +} // Utils namespace Debugger { @@ -43,7 +46,8 @@ public: explicit StartRemoteDialog(QWidget *parent = nullptr); ~StartRemoteDialog() override; - ProjectExplorer::Runnable runnable() const; + Utils::CommandLine commandLine() const; + Utils::FilePath workingDirectory() const; private: void validate(); diff --git a/src/plugins/projectexplorer/runcontrol.cpp b/src/plugins/projectexplorer/runcontrol.cpp index a5926c31134..c2b25204ca4 100644 --- a/src/plugins/projectexplorer/runcontrol.cpp +++ b/src/plugins/projectexplorer/runcontrol.cpp @@ -904,31 +904,46 @@ const Runnable &RunControl::runnable() const return d->runnable; } -void RunControl::setRunnable(const Runnable &runnable) -{ - d->runnable = runnable; -} - const CommandLine &RunControl::commandLine() const { return d->runnable.command; } +void RunControl::setCommandLine(const CommandLine &command) +{ + d->runnable.command = command; +} + const FilePath &RunControl::workingDirectory() const { return d->runnable.workingDirectory; } +void RunControl::setWorkingDirectory(const FilePath &workingDirectory) +{ + d->runnable.workingDirectory = workingDirectory; +} + const Environment &RunControl::environment() const { return d->runnable.environment; } +void RunControl::setEnvironment(const Environment &environment) +{ + d->runnable.environment = environment; +} + const QVariantHash &RunControl::extraData() const { return d->runnable.extraData; } +void RunControl::setExtraData(const QVariantHash &extraData) +{ + d->runnable.extraData = extraData; +} + QString RunControl::displayName() const { return d->displayName; diff --git a/src/plugins/projectexplorer/runcontrol.h b/src/plugins/projectexplorer/runcontrol.h index 6df3f5d365b..09d9149ee2c 100644 --- a/src/plugins/projectexplorer/runcontrol.h +++ b/src/plugins/projectexplorer/runcontrol.h @@ -243,12 +243,18 @@ public: Utils::Id runMode() const; const Runnable &runnable() const; - void setRunnable(const Runnable &runnable); const Utils::CommandLine &commandLine() const; + void setCommandLine(const Utils::CommandLine &command); + const Utils::FilePath &workingDirectory() const; + void setWorkingDirectory(const Utils::FilePath &workingDirectory); + const Utils::Environment &environment() const; + void setEnvironment(const Utils::Environment &environment); + const QVariantHash &extraData() const; + void setExtraData(const QVariantHash &extraData); static bool showPromptToStopDialog(const QString &title, const QString &text, const QString &stopButtonText = QString(), diff --git a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp index 15f30b1025e..8d9b1b834dd 100644 --- a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp +++ b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp @@ -36,6 +36,9 @@ #include #include +using namespace ProjectExplorer; +using namespace Utils; + namespace QmlProfiler { namespace Internal { @@ -45,9 +48,8 @@ LocalQmlProfilerRunnerTest::LocalQmlProfilerRunnerTest(QObject *parent) : QObjec void LocalQmlProfilerRunnerTest::testRunner() { - QPointer runControl; + QPointer runControl; QPointer profiler; - ProjectExplorer::Runnable debuggee; QUrl serverUrl; bool running = false; @@ -56,37 +58,35 @@ void LocalQmlProfilerRunnerTest::testRunner() int runCount = 0; int stopCount = 0; - debuggee.command.setExecutable("\\-/|\\-/"); - debuggee.environment = Utils::Environment::systemEnvironment(); - // should not be used anywhere but cannot be empty serverUrl.setScheme(Utils::urlSocketScheme()); serverUrl.setPath("invalid"); - runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); - runControl->setRunnable(debuggee); + runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); + runControl->setCommandLine({"\\-/|\\-/", {}}); + profiler = new LocalQmlProfilerSupport(runControl, serverUrl); auto connectRunner = [&]() { - connect(runControl, &ProjectExplorer::RunControl::aboutToStart, this, [&]() { + connect(runControl, &RunControl::aboutToStart, this, [&] { QVERIFY(!started); QVERIFY(!running); ++startCount; started = true; }); - connect(runControl, &ProjectExplorer::RunControl::started, this, [&]() { + connect(runControl, &RunControl::started, this, [&] { QVERIFY(started); QVERIFY(!running); ++runCount; running = true; }); - connect(runControl, &ProjectExplorer::RunControl::stopped, this, [&]() { + connect(runControl, &RunControl::stopped, this, [&] { QVERIFY(started); ++stopCount; running = false; started = false; }); - connect(runControl, &ProjectExplorer::RunControl::finished, this, [&]() { + connect(runControl, &RunControl::finished, this, [&]{ running = false; started = false; }); @@ -110,10 +110,10 @@ void LocalQmlProfilerRunnerTest::testRunner() serverUrl = Utils::urlFromLocalSocket(); // comma is used to specify a test function. In this case, an invalid one. - debuggee.command = Utils::CommandLine(Utils::FilePath::fromString(QCoreApplication::applicationFilePath()), - {"-test", "QmlProfiler,"}); - runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); - runControl->setRunnable(debuggee); + runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); + + const FilePath app = FilePath::fromString(QCoreApplication::applicationFilePath()); + runControl->setCommandLine({app, {"-test", "QmlProfiler,"}}); profiler = new LocalQmlProfilerSupport(runControl, serverUrl); connectRunner(); runControl->initiateStart(); @@ -128,11 +128,10 @@ void LocalQmlProfilerRunnerTest::testRunner() QTRY_VERIFY(runControl.isNull()); QVERIFY(profiler.isNull()); - debuggee.command.setArguments({}); serverUrl.clear(); serverUrl = Utils::urlFromLocalHostAndFreePort(); - runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); - runControl->setRunnable(debuggee); + runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); + runControl->setCommandLine({app, {}}); profiler = new LocalQmlProfilerSupport(runControl, serverUrl); connectRunner(); runControl->initiateStart(); @@ -148,7 +147,6 @@ void LocalQmlProfilerRunnerTest::testRunner() QTRY_VERIFY(runControl.isNull()); QVERIFY(profiler.isNull()); - debuggee.command.setArguments("-test QmlProfiler,"); serverUrl.setScheme(Utils::urlSocketScheme()); { Utils::TemporaryFile file("file with spaces"); @@ -156,8 +154,8 @@ void LocalQmlProfilerRunnerTest::testRunner() serverUrl.setPath(file.fileName()); } - runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); - runControl->setRunnable(debuggee); + runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); + runControl->setCommandLine({app, {"-test", "QmlProfiler,"}}); profiler = new LocalQmlProfilerSupport(runControl, serverUrl); connectRunner(); runControl->initiateStart(); diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index f5cef8600de..a3bf69504f5 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -282,12 +282,13 @@ CallgrindToolPrivate::CallgrindToolPrivate() if (dlg.exec() != QDialog::Accepted) return; m_perspective.select(); + CommandLine command = dlg.commandLine(); auto runControl = new RunControl(CALLGRIND_RUN_MODE); runControl->copyDataFromRunConfiguration(runConfig); runControl->createMainWorker(); - const auto runnable = dlg.runnable(); - runControl->setRunnable(runnable); - runControl->setDisplayName(runnable.command.executable().toUserOutput()); + runControl->setCommandLine(command); + runControl->setWorkingDirectory(dlg.workingDirectory()); + runControl->setDisplayName(command.executable().toUserOutput()); ProjectExplorerPlugin::startRunControl(runControl); }); diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index 183daa80256..31decb2da31 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -704,12 +704,13 @@ MemcheckToolPrivate::MemcheckToolPrivate() return; TaskHub::clearTasks(Debugger::Constants::ANALYZERTASK_ID); m_perspective.select(); + const CommandLine cmd = dlg.commandLine(); RunControl *rc = new RunControl(MEMCHECK_RUN_MODE); rc->copyDataFromRunConfiguration(runConfig); rc->createMainWorker(); - const auto runnable = dlg.runnable(); - rc->setRunnable(runnable); - rc->setDisplayName(runnable.command.executable().toUserOutput()); + rc->setCommandLine(cmd); + rc->setWorkingDirectory(dlg.workingDirectory()); + rc->setDisplayName(cmd.toUserOutput()); ProjectExplorerPlugin::startRunControl(rc); });