From c813b5f31cde78fd40f5284202820eb759a7cfe2 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 3 May 2016 10:30:56 +0200 Subject: [PATCH] Make local custom executables run independent of device selection Task-number: QTCREATORBUG-16199 Change-Id: I1e9e2103e626c6480fa1c5ac9b2b3f8ac93e3038 Reviewed-by: Christian Kandeler Reviewed-by: Tobias Hunger --- src/plugins/debugger/debuggerruncontrol.cpp | 8 ++++++++ .../projectexplorer/localapplicationruncontrol.cpp | 12 +++++++++--- src/plugins/projectexplorer/runnables.h | 1 + .../qtsupport/customexecutablerunconfiguration.cpp | 2 ++ src/plugins/valgrind/valgrindengine.cpp | 5 +++-- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index 0181bd6e4a9..9f077c46527 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -598,6 +598,14 @@ public: { if (!(mode == DebugRunMode || mode == DebugRunModeWithBreakOnMain)) return false; + + Runnable runnable = runConfig->runnable(); + if (runnable.is()) { + IDevice::ConstPtr device = runnable.as().device; + if (device && device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) + return true; + } + return DeviceTypeKitInformation::deviceTypeId(runConfig->target()->kit()) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE || isDebuggableScript(runConfig); diff --git a/src/plugins/projectexplorer/localapplicationruncontrol.cpp b/src/plugins/projectexplorer/localapplicationruncontrol.cpp index 02afe6d422b..9c20ad71f2d 100644 --- a/src/plugins/projectexplorer/localapplicationruncontrol.cpp +++ b/src/plugins/projectexplorer/localapplicationruncontrol.cpp @@ -138,9 +138,15 @@ static bool isLocal(RunConfiguration *runConfiguration) bool LocalApplicationRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const { - return mode == Constants::NORMAL_RUN_MODE - && isLocal(runConfiguration) - && runConfiguration->runnable().is(); + if (mode != Constants::NORMAL_RUN_MODE) + return false; + const Runnable runnable = runConfiguration->runnable(); + if (!runnable.is()) + return false; + const IDevice::ConstPtr device = runnable.as().device; + if (device && device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) + return true; + return isLocal(runConfiguration); } RunControl *LocalApplicationRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) diff --git a/src/plugins/projectexplorer/runnables.h b/src/plugins/projectexplorer/runnables.h index 5e4c94774c9..3949b80a0b5 100644 --- a/src/plugins/projectexplorer/runnables.h +++ b/src/plugins/projectexplorer/runnables.h @@ -42,6 +42,7 @@ public: QString workingDirectory; Utils::Environment environment; ApplicationLauncher::Mode runMode = ApplicationLauncher::Gui; + IDevice::ConstPtr device; // Override the kit's device. Keep unset by default. }; PROJECTEXPLORER_EXPORT bool operator==(const StandardRunnable &r1, const StandardRunnable &r2); diff --git a/src/plugins/qtsupport/customexecutablerunconfiguration.cpp b/src/plugins/qtsupport/customexecutablerunconfiguration.cpp index c1c79f1e3d3..a212866c327 100644 --- a/src/plugins/qtsupport/customexecutablerunconfiguration.cpp +++ b/src/plugins/qtsupport/customexecutablerunconfiguration.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -253,6 +254,7 @@ Runnable CustomExecutableRunConfiguration::runnable() const r.workingDirectory = workingDirectory(); r.environment = extraAspect()->environment(); r.runMode = extraAspect()->runMode(); + r.device = DeviceManager::instance()->defaultDevice(Constants::DESKTOP_DEVICE_TYPE); return r; } diff --git a/src/plugins/valgrind/valgrindengine.cpp b/src/plugins/valgrind/valgrindengine.cpp index 935bc1f2434..dde2ae7fd0e 100644 --- a/src/plugins/valgrind/valgrindengine.cpp +++ b/src/plugins/valgrind/valgrindengine.cpp @@ -85,8 +85,9 @@ void ValgrindRunControl::start() ValgrindRunner *run = runner(); run->setValgrindExecutable(m_settings->valgrindExecutable()); run->setValgrindArguments(genericToolArguments() + toolArguments()); - run->setDevice(device()); - run->setDebuggee(runnable().as()); + const StandardRunnable r = runnable().as(); + run->setDevice(r.device ? r.device : device()); + run->setDebuggee(r); connect(run, &ValgrindRunner::processOutputReceived, this, &ValgrindRunControl::receiveProcessOutput);