aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2017-03-13 17:01:59 +0100
committerhjk <hjk@qt.io>2017-03-22 09:24:51 +0000
commit23564832059a8f96f2f5277a49085b308fca8faf (patch)
tree777642c34530bea8deb4cef9e24b1df4fcef116d
parent4d3c297d024a86201d70d478beffa61176ac1e82 (diff)
ProjectExplorer/QNX/RemoteLinux: Merge {RemoteLinux,Simple}RunControl
Currently still kind-of-two implementations due to the kind-of-two current ApplicationLauncher message handling, but getting one step closer to a unified implementation. This also de-emphasizes the "wrong" QNX-IS-A-RemoteLinux relation by removing the QnxRunControl inheritance of RemoteLinuxRunControl. Change-Id: Iec8abaa53223a5a47ec51817b3994d37d444557a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: James McDonnell <jmcdonnell@blackberry.com> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
-rw-r--r--src/plugins/projectexplorer/runconfiguration.cpp95
-rw-r--r--src/plugins/projectexplorer/runconfiguration.h4
-rw-r--r--src/plugins/qnx/qnxruncontrol.cpp5
-rw-r--r--src/plugins/qnx/qnxruncontrol.h9
-rw-r--r--src/plugins/remotelinux/remotelinux.pro2
-rw-r--r--src/plugins/remotelinux/remotelinux.qbs2
-rw-r--r--src/plugins/remotelinux/remotelinuxruncontrol.cpp108
-rw-r--r--src/plugins/remotelinux/remotelinuxruncontrol.h56
-rw-r--r--src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp3
9 files changed, 83 insertions, 201 deletions
diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp
index da5c7b398b..4bacf18638 100644
--- a/src/plugins/projectexplorer/runconfiguration.cpp
+++ b/src/plugins/projectexplorer/runconfiguration.cpp
@@ -802,6 +802,16 @@ public:
} // Internal
+// FIXME: Remove once ApplicationLauncher signalling does not depend on device.
+static bool isSynchronousLauncher(RunControl *runControl)
+{
+ RunConfiguration *runConfig = runControl->runConfiguration();
+ Target *target = runConfig ? runConfig->target() : nullptr;
+ Kit *kit = target ? target->kit() : nullptr;
+ Core::Id deviceId = DeviceTypeKitInformation::deviceTypeId(kit);
+ return !deviceId.isValid() || deviceId == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
+}
+
SimpleRunControl::SimpleRunControl(RunConfiguration *runConfiguration, Core::Id mode)
: RunControl(runConfiguration, mode), d(new Internal::SimpleRunControlPrivate)
{
@@ -824,35 +834,76 @@ void SimpleRunControl::start()
reportApplicationStart();
d->m_launcher.disconnect(this);
- connect(&d->m_launcher, &ApplicationLauncher::appendMessage,
- this, static_cast<void(RunControl::*)(const QString &, Utils::OutputFormat)>(&RunControl::appendMessage));
- connect(&d->m_launcher, &ApplicationLauncher::processStarted,
- this, &SimpleRunControl::onProcessStarted);
- connect(&d->m_launcher, &ApplicationLauncher::processExited,
- this, &SimpleRunControl::onProcessFinished);
-
- QTC_ASSERT(runnable().is<StandardRunnable>(), return);
- auto r = runnable().as<StandardRunnable>();
- if (r.executable.isEmpty()) {
- appendMessage(RunControl::tr("No executable specified.") + QLatin1Char('\n'), Utils::ErrorMessageFormat);
- reportApplicationStop();
- } else if (!QFileInfo::exists(r.executable)) {
- appendMessage(RunControl::tr("Executable %1 does not exist.")
- .arg(QDir::toNativeSeparators(r.executable)) + QLatin1Char('\n'),
- Utils::ErrorMessageFormat);
- reportApplicationStop();
+ Runnable r = runnable();
+
+ if (isSynchronousLauncher(this)) {
+
+ connect(&d->m_launcher, &ApplicationLauncher::appendMessage,
+ this, static_cast<void(RunControl::*)(const QString &, OutputFormat)>(&RunControl::appendMessage));
+ connect(&d->m_launcher, &ApplicationLauncher::processStarted,
+ this, &SimpleRunControl::onProcessStarted);
+ connect(&d->m_launcher, &ApplicationLauncher::processExited,
+ this, &SimpleRunControl::onProcessFinished);
+
+ QTC_ASSERT(r.is<StandardRunnable>(), return);
+ const QString executable = r.as<StandardRunnable>().executable;
+ if (executable.isEmpty()) {
+ appendMessage(RunControl::tr("No executable specified.") + '\n',
+ Utils::ErrorMessageFormat);
+ reportApplicationStop();
+ } else if (!QFileInfo::exists(executable)) {
+ appendMessage(RunControl::tr("Executable %1 does not exist.")
+ .arg(QDir::toNativeSeparators(executable)) + '\n',
+ Utils::ErrorMessageFormat);
+ reportApplicationStop();
+ } else {
+ QString msg = RunControl::tr("Starting %1...").arg(QDir::toNativeSeparators(executable)) + '\n';
+ appendMessage(msg, Utils::NormalMessageFormat);
+ d->m_launcher.start(r);
+ setApplicationProcessHandle(d->m_launcher.applicationPID());
+ }
+
} else {
- QString msg = RunControl::tr("Starting %1...").arg(QDir::toNativeSeparators(r.executable)) + QLatin1Char('\n');
- appendMessage(msg, Utils::NormalMessageFormat);
- d->m_launcher.start(r);
- setApplicationProcessHandle(d->m_launcher.applicationPID());
+
+ connect(&d->m_launcher, &ApplicationLauncher::reportError,
+ this, [this](const QString &error) {
+ appendMessage(error, Utils::ErrorMessageFormat);
+ });
+
+ connect(&d->m_launcher, &ApplicationLauncher::remoteStderr,
+ this, [this](const QByteArray &output) {
+ appendMessage(QString::fromUtf8(output), Utils::StdErrFormatSameLine);
+ });
+
+ connect(&d->m_launcher, &ApplicationLauncher::remoteStdout,
+ this, [this](const QByteArray &output) {
+ appendMessage(QString::fromUtf8(output), Utils::StdOutFormatSameLine);
+ });
+
+ connect(&d->m_launcher, &ApplicationLauncher::finished,
+ this, [this] {
+ d->m_launcher.disconnect(this);
+ reportApplicationStop();
+ });
+
+ connect(&d->m_launcher, &ApplicationLauncher::reportProgress,
+ this, [this](const QString &progressString) {
+ appendMessage(progressString + '\n', Utils::NormalMessageFormat);
+ });
+
+ d->m_launcher.start(r, device());
+
}
}
RunControl::StopResult SimpleRunControl::stop()
{
d->m_launcher.stop();
- return StoppedSynchronously;
+
+ if (isSynchronousLauncher(this))
+ return StoppedSynchronously;
+ else
+ return AsynchronousStop;
}
void SimpleRunControl::onProcessStarted()
diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h
index e6ad09513e..0290fd3d96 100644
--- a/src/plugins/projectexplorer/runconfiguration.h
+++ b/src/plugins/projectexplorer/runconfiguration.h
@@ -431,7 +431,9 @@ public:
virtual void onProcessFinished(int exitCode, QProcess::ExitStatus status);
private:
- Internal::SimpleRunControlPrivate *d;
+ void setFinished();
+
+ Internal::SimpleRunControlPrivate * const d;
};
} // namespace ProjectExplorer
diff --git a/src/plugins/qnx/qnxruncontrol.cpp b/src/plugins/qnx/qnxruncontrol.cpp
index 79e20fbd6f..bf0fb99264 100644
--- a/src/plugins/qnx/qnxruncontrol.cpp
+++ b/src/plugins/qnx/qnxruncontrol.cpp
@@ -33,14 +33,13 @@
#include <projectexplorer/target.h>
using namespace ProjectExplorer;
-using namespace RemoteLinux;
using namespace Utils;
namespace Qnx {
namespace Internal {
QnxRunControl::QnxRunControl(RunConfiguration *runConfig)
- : RemoteLinuxRunControl(runConfig)
+ : SimpleRunControl(runConfig, ProjectExplorer::Constants::NORMAL_RUN_MODE)
, m_slog2Info(0)
{
IDevice::ConstPtr dev = DeviceKitInformation::device(runConfig->target()->kit());
@@ -61,7 +60,7 @@ QnxRunControl::QnxRunControl(RunConfiguration *runConfig)
RunControl::StopResult QnxRunControl::stop()
{
m_slog2Info->stop();
- return RemoteLinuxRunControl::stop();
+ return SimpleRunControl::stop();
}
void QnxRunControl::printMissingWarning()
diff --git a/src/plugins/qnx/qnxruncontrol.h b/src/plugins/qnx/qnxruncontrol.h
index 61985f6daa..b0891d7a4d 100644
--- a/src/plugins/qnx/qnxruncontrol.h
+++ b/src/plugins/qnx/qnxruncontrol.h
@@ -25,25 +25,24 @@
#pragma once
-#include <remotelinux/remotelinuxruncontrol.h>
+#include <projectexplorer/runconfiguration.h>
namespace Qnx {
namespace Internal {
class Slog2InfoRunner;
-class QnxRunControl : public RemoteLinux::RemoteLinuxRunControl
+class QnxRunControl : public ProjectExplorer::SimpleRunControl
{
Q_OBJECT
public:
explicit QnxRunControl(ProjectExplorer::RunConfiguration *runConfig);
- RemoteLinux::RemoteLinuxRunControl::StopResult stop() override;
+ StopResult stop() override;
-private slots:
+private:
void printMissingWarning();
-private:
Slog2InfoRunner *m_slog2Info;
};
diff --git a/src/plugins/remotelinux/remotelinux.pro b/src/plugins/remotelinux/remotelinux.pro
index 9f1683508d..570034882e 100644
--- a/src/plugins/remotelinux/remotelinux.pro
+++ b/src/plugins/remotelinux/remotelinux.pro
@@ -16,7 +16,6 @@ HEADERS += \
genericlinuxdeviceconfigurationfactory.h \
remotelinuxrunconfigurationwidget.h \
remotelinuxrunconfigurationfactory.h \
- remotelinuxruncontrol.h \
remotelinuxruncontrolfactory.h \
remotelinuxdebugsupport.h \
genericlinuxdeviceconfigurationwizardpages.h \
@@ -64,7 +63,6 @@ SOURCES += \
genericlinuxdeviceconfigurationfactory.cpp \
remotelinuxrunconfigurationwidget.cpp \
remotelinuxrunconfigurationfactory.cpp \
- remotelinuxruncontrol.cpp \
remotelinuxruncontrolfactory.cpp \
remotelinuxdebugsupport.cpp \
genericlinuxdeviceconfigurationwizardpages.cpp \
diff --git a/src/plugins/remotelinux/remotelinux.qbs b/src/plugins/remotelinux/remotelinux.qbs
index a651d581a2..27fce5dbb8 100644
--- a/src/plugins/remotelinux/remotelinux.qbs
+++ b/src/plugins/remotelinux/remotelinux.qbs
@@ -98,8 +98,6 @@ Project {
"remotelinuxrunconfigurationfactory.h",
"remotelinuxrunconfigurationwidget.cpp",
"remotelinuxrunconfigurationwidget.h",
- "remotelinuxruncontrol.cpp",
- "remotelinuxruncontrol.h",
"remotelinuxruncontrolfactory.cpp",
"remotelinuxruncontrolfactory.h",
"remotelinuxsignaloperation.cpp",
diff --git a/src/plugins/remotelinux/remotelinuxruncontrol.cpp b/src/plugins/remotelinux/remotelinuxruncontrol.cpp
deleted file mode 100644
index 4fca73096f..0000000000
--- a/src/plugins/remotelinux/remotelinuxruncontrol.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "remotelinuxruncontrol.h"
-
-#include <projectexplorer/applicationlauncher.h>
-
-#include <utils/utilsicons.h>
-
-using namespace ProjectExplorer;
-
-namespace RemoteLinux {
-
-class RemoteLinuxRunControl::RemoteLinuxRunControlPrivate
-{
-public:
- ApplicationLauncher launcher;
-};
-
-RemoteLinuxRunControl::RemoteLinuxRunControl(RunConfiguration *rc)
- : RunControl(rc, ProjectExplorer::Constants::NORMAL_RUN_MODE), d(new RemoteLinuxRunControlPrivate)
-{
- setIcon(Utils::Icons::RUN_SMALL_TOOLBAR);
- setRunnable(rc->runnable());
-}
-
-RemoteLinuxRunControl::~RemoteLinuxRunControl()
-{
- delete d;
-}
-
-void RemoteLinuxRunControl::start()
-{
- reportApplicationStart();
- d->launcher.disconnect(this);
- connect(&d->launcher, &ApplicationLauncher::reportError,
- this, &RemoteLinuxRunControl::handleErrorMessage);
- connect(&d->launcher, &ApplicationLauncher::remoteStderr,
- this, &RemoteLinuxRunControl::handleRemoteErrorOutput);
- connect(&d->launcher, &ApplicationLauncher::remoteStdout,
- this, &RemoteLinuxRunControl::handleRemoteOutput);
- connect(&d->launcher, &ApplicationLauncher::finished,
- this, &RemoteLinuxRunControl::handleRunnerFinished);
- connect(&d->launcher, &ApplicationLauncher::reportProgress,
- this, &RemoteLinuxRunControl::handleProgressReport);
- d->launcher.start(runnable(), device());
-}
-
-RunControl::StopResult RemoteLinuxRunControl::stop()
-{
- d->launcher.stop();
- return AsynchronousStop;
-}
-
-void RemoteLinuxRunControl::handleErrorMessage(const QString &error)
-{
- appendMessage(error, Utils::ErrorMessageFormat);
-}
-
-void RemoteLinuxRunControl::handleRunnerFinished()
-{
- setFinished();
-}
-
-void RemoteLinuxRunControl::handleRemoteOutput(const QByteArray &output)
-{
- appendMessage(QString::fromUtf8(output), Utils::StdOutFormatSameLine);
-}
-
-void RemoteLinuxRunControl::handleRemoteErrorOutput(const QByteArray &output)
-{
- appendMessage(QString::fromUtf8(output), Utils::StdErrFormatSameLine);
-}
-
-void RemoteLinuxRunControl::handleProgressReport(const QString &progressString)
-{
- appendMessage(progressString + QLatin1Char('\n'), Utils::NormalMessageFormat);
-}
-
-void RemoteLinuxRunControl::setFinished()
-{
- d->launcher.disconnect(this);
- reportApplicationStop();
-}
-
-} // namespace RemoteLinux
diff --git a/src/plugins/remotelinux/remotelinuxruncontrol.h b/src/plugins/remotelinux/remotelinuxruncontrol.h
deleted file mode 100644
index 8582d3013b..0000000000
--- a/src/plugins/remotelinux/remotelinuxruncontrol.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#pragma once
-
-#include "remotelinux_export.h"
-
-#include <projectexplorer/runconfiguration.h>
-
-namespace RemoteLinux {
-
-class REMOTELINUX_EXPORT RemoteLinuxRunControl : public ProjectExplorer::RunControl
-{
- Q_OBJECT
-public:
- explicit RemoteLinuxRunControl(ProjectExplorer::RunConfiguration *runConfig);
- ~RemoteLinuxRunControl() override;
-
- virtual void start() override;
- virtual StopResult stop() override;
-
-private:
- void handleErrorMessage(const QString &error);
- void handleRunnerFinished();
- void handleRemoteOutput(const QByteArray &output);
- void handleRemoteErrorOutput(const QByteArray &output);
- void handleProgressReport(const QString &progressString);
- void setFinished();
-
- class RemoteLinuxRunControlPrivate;
- RemoteLinuxRunControlPrivate * const d;
-};
-
-} // namespace RemoteLinux
diff --git a/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp b/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp
index de74408271..b7e371f29a 100644
--- a/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp
+++ b/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp
@@ -29,7 +29,6 @@
#include "remotelinuxdebugsupport.h"
#include "remotelinuxcustomrunconfiguration.h"
#include "remotelinuxrunconfiguration.h"
-#include "remotelinuxruncontrol.h"
#include <debugger/analyzer/analyzermanager.h>
#include <debugger/analyzer/analyzerruncontrol.h>
@@ -82,7 +81,7 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Co
QTC_ASSERT(canRun(runConfig, mode), return 0);
if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE)
- return new RemoteLinuxRunControl(runConfig);
+ return new SimpleRunControl(runConfig, mode);
const auto rcRunnable = runConfig->runnable();
QTC_ASSERT(rcRunnable.is<StandardRunnable>(), return 0);