diff --git a/src/plugins/boot2qt/qdbdevice.cpp b/src/plugins/boot2qt/qdbdevice.cpp index c7f59337ec2..f14990c9eb7 100644 --- a/src/plugins/boot2qt/qdbdevice.cpp +++ b/src/plugins/boot2qt/qdbdevice.cpp @@ -35,7 +35,6 @@ #include #include -#include #include #include @@ -56,26 +55,6 @@ using namespace Utils; namespace Qdb { namespace Internal { -class QdbDeviceProcess : public RemoteLinux::LinuxDeviceProcess -{ -public: - QdbDeviceProcess(const QSharedPointer &device, QObject *parent) - : RemoteLinux::LinuxDeviceProcess(device, parent) - { - } - - void terminate() override - { - ProjectExplorer::Runnable r; - r.command = {Constants::AppcontrollerFilepath, {"--stop"}}; - r.device = device(); - - auto launcher = new ApplicationLauncher(this); - launcher->setRunnable(r); - launcher->start(); - } -}; - class QdbProcessImpl : public LinuxProcessInterface { public: @@ -183,11 +162,6 @@ ProjectExplorer::IDeviceWidget *QdbDevice::createWidget() return w; } -QtcProcess *QdbDevice::createProcess(QObject *parent) const -{ - return new QdbDeviceProcess(sharedFromThis(), parent); -} - ProcessInterface *QdbDevice::createProcessInterface() const { return new QdbProcessImpl(this); diff --git a/src/plugins/boot2qt/qdbdevice.h b/src/plugins/boot2qt/qdbdevice.h index 1e55799614e..fce5d79f0bd 100644 --- a/src/plugins/boot2qt/qdbdevice.h +++ b/src/plugins/boot2qt/qdbdevice.h @@ -44,7 +44,6 @@ public: ProjectExplorer::IDeviceWidget *createWidget() final; - Utils::QtcProcess *createProcess(QObject *parent) const final; Utils::ProcessInterface *createProcessInterface() const override; void setSerialNumber(const QString &serial); diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp index eccf1716be9..35cd37b7351 100644 --- a/src/plugins/docker/dockerdevice.cpp +++ b/src/plugins/docker/dockerdevice.cpp @@ -104,52 +104,6 @@ const QString s_pidMarker = "__qtc$$qtc__"; static Q_LOGGING_CATEGORY(dockerDeviceLog, "qtc.docker.device", QtWarningMsg); #define LOG(x) qCDebug(dockerDeviceLog) << this << x << '\n' -class DockerDeviceProcess : public Utils::QtcProcess -{ -public: - DockerDeviceProcess(const QSharedPointer &device, QObject *parent = nullptr); - ~DockerDeviceProcess() {} - - void startImpl() override; - void interrupt() override; - - const QSharedPointer m_device; -}; - -DockerDeviceProcess::DockerDeviceProcess(const QSharedPointer &device, - QObject *parent) - : QtcProcess(parent), m_device(device) -{ - setProcessMode(ProcessMode::Writer); -} - -void DockerDeviceProcess::startImpl() -{ - QTC_ASSERT(state() == QProcess::NotRunning, return); - DockerDevice::ConstPtr dockerDevice = qSharedPointerCast(m_device); - QTC_ASSERT(dockerDevice, return); - - connect(this, &QtcProcess::readyReadStandardOutput, this, [this] { - MessageManager::writeSilently(QString::fromLocal8Bit(readAllStandardError())); - }); - connect(this, &QtcProcess::readyReadStandardError, this, [this] { - MessageManager::writeDisrupting(QString::fromLocal8Bit(readAllStandardError())); - }); - - CommandLine command = commandLine(); - command.setExecutable( - command.executable().withNewPath(dockerDevice->mapToDevicePath(command.executable()))); - setCommand(command); - - LOG("Running process:" << command.toUserOutput() << "in" << workingDirectory().toUserOutput()); - QtcProcess::startImpl(); -} - -void DockerDeviceProcess::interrupt() -{ - m_device->signalOperation()->interruptProcess(processId()); -} - class DockerPortsGatheringMethod : public PortsGatheringMethod { CommandLine commandLine(QAbstractSocket::NetworkLayerProtocol protocol) const override @@ -655,11 +609,6 @@ QVariantMap DockerDevice::toMap() const return map; } -QtcProcess *DockerDevice::createProcess(QObject *parent) const -{ - return new DockerDeviceProcess(sharedFromThis(), parent); -} - ProcessInterface *DockerDevice::createProcessInterface() const { return new DockerProcessImpl(d); diff --git a/src/plugins/docker/dockerdevice.h b/src/plugins/docker/dockerdevice.h index d14226487ba..c14aea2be0e 100644 --- a/src/plugins/docker/dockerdevice.h +++ b/src/plugins/docker/dockerdevice.h @@ -63,8 +63,6 @@ public: ProjectExplorer::IDeviceWidget *createWidget() override; QList validate() const override; - bool canCreateProcess() const override { return true; } - Utils::QtcProcess *createProcess(QObject *parent) const override; Utils::ProcessInterface *createProcessInterface() const override; bool canAutoDetectPorts() const override; diff --git a/src/plugins/docker/dockerdevicewidget.cpp b/src/plugins/docker/dockerdevicewidget.cpp index 147e45083f6..0c1e6840538 100644 --- a/src/plugins/docker/dockerdevicewidget.cpp +++ b/src/plugins/docker/dockerdevicewidget.cpp @@ -25,12 +25,12 @@ #include "dockerdevicewidget.h" -#include -#include -#include #include +#include +#include #include #include +#include #include #include diff --git a/src/plugins/projectexplorer/CMakeLists.txt b/src/plugins/projectexplorer/CMakeLists.txt index 65938ecd3a3..07c0fa0679d 100644 --- a/src/plugins/projectexplorer/CMakeLists.txt +++ b/src/plugins/projectexplorer/CMakeLists.txt @@ -66,8 +66,6 @@ add_qtc_plugin(ProjectExplorer devicesupport/idevicefwd.h devicesupport/idevicewidget.h devicesupport/localprocesslist.cpp devicesupport/localprocesslist.h - devicesupport/sshdeviceprocess.cpp devicesupport/sshdeviceprocess.h - devicesupport/sshdeviceprocess.cpp devicesupport/sshdeviceprocess.h devicesupport/sshdeviceprocesslist.cpp devicesupport/sshdeviceprocesslist.h devicesupport/sshsettingspage.cpp devicesupport/sshsettingspage.h editorconfiguration.cpp editorconfiguration.h diff --git a/src/plugins/projectexplorer/applicationlauncher.cpp b/src/plugins/projectexplorer/applicationlauncher.cpp index 93782b5ff3d..6b4f2e1cd4b 100644 --- a/src/plugins/projectexplorer/applicationlauncher.cpp +++ b/src/plugins/projectexplorer/applicationlauncher.cpp @@ -377,15 +377,6 @@ void ApplicationLauncherPrivate::start() return; } - if (!m_runnable.device->canCreateProcess()) { - m_resultData.m_errorString =ApplicationLauncher::tr("Cannot run: Device is not able to create processes."); - m_resultData.m_error = QProcess::FailedToStart; - m_resultData.m_exitStatus = QProcess::CrashExit; - emit q->errorOccurred(QProcess::FailedToStart); - emit q->finished(); - return; - } - if (!m_runnable.device->isEmptyCommandAllowed() && m_runnable.command.isEmpty()) { m_resultData.m_errorString = ApplicationLauncher::tr("Cannot run: No command given."); m_resultData.m_error = QProcess::FailedToStart; diff --git a/src/plugins/projectexplorer/devicesupport/desktopdevice.cpp b/src/plugins/projectexplorer/devicesupport/desktopdevice.cpp index 17d2d52e70a..981b9d07799 100644 --- a/src/plugins/projectexplorer/devicesupport/desktopdevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/desktopdevice.cpp @@ -97,11 +97,6 @@ DeviceProcessList *DesktopDevice::createProcessListModel(QObject *parent) const return new Internal::LocalProcessList(sharedFromThis(), parent); } -QtcProcess *DesktopDevice::createProcess(QObject *parent) const -{ - return new QtcProcess(parent); -} - DeviceProcessSignalOperation::Ptr DesktopDevice::signalOperation() const { return DeviceProcessSignalOperation::Ptr(new DesktopProcessSignalOperation()); diff --git a/src/plugins/projectexplorer/devicesupport/desktopdevice.h b/src/plugins/projectexplorer/devicesupport/desktopdevice.h index 0454c9c13cb..ee8aa70e191 100644 --- a/src/plugins/projectexplorer/devicesupport/desktopdevice.h +++ b/src/plugins/projectexplorer/devicesupport/desktopdevice.h @@ -48,9 +48,7 @@ public: bool canAutoDetectPorts() const override; bool canCreateProcessModel() const override; DeviceProcessList *createProcessListModel(QObject *parent) const override; - bool canCreateProcess() const override { return true; } ProjectExplorer::PortsGatheringMethod::Ptr portsGatheringMethod() const override; - Utils::QtcProcess *createProcess(QObject *parent) const override; DeviceProcessSignalOperation::Ptr signalOperation() const override; DeviceEnvironmentFetcher::Ptr environmentFetcher() const override; QUrl toolControlChannel(const ControlChannelHint &) const override; diff --git a/src/plugins/projectexplorer/devicesupport/idevice.cpp b/src/plugins/projectexplorer/devicesupport/idevice.cpp index b04f56f3fad..8fbae8a6710 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/idevice.cpp @@ -583,12 +583,6 @@ OsType IDevice::osType() const return d->osType; } -QtcProcess *IDevice::createProcess(QObject * /* parent */) const -{ - QTC_CHECK(false); - return nullptr; -} - DeviceEnvironmentFetcher::Ptr IDevice::environmentFetcher() const { return DeviceEnvironmentFetcher::Ptr(); diff --git a/src/plugins/projectexplorer/devicesupport/idevice.h b/src/plugins/projectexplorer/devicesupport/idevice.h index 05e023102c6..000424dfb44 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.h +++ b/src/plugins/projectexplorer/devicesupport/idevice.h @@ -181,8 +181,6 @@ public: virtual bool hasDeviceTester() const { return false; } virtual DeviceTester *createDeviceTester() const; - virtual bool canCreateProcess() const { return false; } - virtual Utils::QtcProcess *createProcess(QObject *parent) const; virtual DeviceProcessSignalOperation::Ptr signalOperation() const = 0; virtual DeviceEnvironmentFetcher::Ptr environmentFetcher() const; diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp deleted file mode 100644 index 061996286b6..00000000000 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp +++ /dev/null @@ -1,335 +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 "sshdeviceprocess.h" - -#include "idevice.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -using namespace Utils; - -namespace ProjectExplorer { - -enum class Signal { Interrupt, Terminate, Kill }; - -class SshDeviceProcess::SshDeviceProcessPrivate -{ -public: - SshDeviceProcessPrivate(SshDeviceProcess *q) : q(q) {} - - SshDeviceProcess * const q; - QSharedPointer m_device; - QSsh::SshConnection *connection = nullptr; - QSsh::SshRemoteProcessPtr remoteProcess; - QString processName; - QString displayName; - QString errorMessage; - QProcess::ExitStatus exitStatus = QProcess::NormalExit; - DeviceProcessSignalOperation::Ptr killOperation; - QTimer killTimer; - enum State { Inactive, Connecting, Connected, ProcessRunning } state = Inactive; - - void setState(State newState); - void doSignal(Signal signal); -}; - -SshDeviceProcess::SshDeviceProcess(const IDevice::ConstPtr &device, QObject *parent) - : QtcProcess(parent), - d(std::make_unique(this)) -{ - d->m_device = device; - connect(&d->killTimer, &QTimer::timeout, this, &SshDeviceProcess::handleKillOperationTimeout); -} - -void SshDeviceProcess::emitStarted() -{ - handleProcessStarted(); -} - -void SshDeviceProcess::emitFinished() -{ - handleProcessFinished(QtcProcess::errorString()); -} - -const QSharedPointer &SshDeviceProcess::device() const -{ - return d->m_device; -} - -SshDeviceProcess::~SshDeviceProcess() -{ - d->setState(SshDeviceProcessPrivate::Inactive); -} - -void SshDeviceProcess::startImpl() -{ - QTC_ASSERT(d->state == SshDeviceProcessPrivate::Inactive, return); - QTC_ASSERT(usesTerminal() || !commandLine().isEmpty(), return); - d->setState(SshDeviceProcessPrivate::Connecting); - - d->errorMessage.clear(); - d->exitStatus = QProcess::NormalExit; - d->processName = commandLine().executable().toString(); - d->displayName = extraData("Ssh.X11ForwardToDisplay").toString(); - - QSsh::SshConnectionParameters params = d->m_device->sshParameters(); - params.x11DisplayName = d->displayName; - d->connection = QSsh::SshConnectionManager::acquireConnection(params); - connect(d->connection, &QSsh::SshConnection::errorOccurred, - this, &SshDeviceProcess::handleConnectionError); - connect(d->connection, &QSsh::SshConnection::disconnected, - this, &SshDeviceProcess::handleDisconnected); - if (d->connection->state() == QSsh::SshConnection::Connected) { - handleConnected(); - } else { - connect(d->connection, &QSsh::SshConnection::connected, - this, &SshDeviceProcess::handleConnected); - if (d->connection->state() == QSsh::SshConnection::Unconnected) - d->connection->connectToHost(); - } -} - -void SshDeviceProcess::interrupt() -{ - QTC_ASSERT(d->state == SshDeviceProcessPrivate::ProcessRunning, return); - d->doSignal(Signal::Interrupt); -} - -void SshDeviceProcess::terminate() -{ - QTC_ASSERT(d->state == SshDeviceProcessPrivate::ProcessRunning, return); - d->doSignal(Signal::Terminate); -} - -void SshDeviceProcess::kill() -{ - QTC_ASSERT(d->state == SshDeviceProcessPrivate::ProcessRunning, return); - d->doSignal(Signal::Kill); -} - -ProcessResultData SshDeviceProcess::resultData() const -{ - const ProcessResultData result = QtcProcess::resultData(); - return { usesTerminal() ? result.m_exitCode : d->remoteProcess->exitCode(), - d->exitStatus == QProcess::NormalExit && result.m_exitCode != 255 - ? QProcess::NormalExit : QProcess::CrashExit, - result.m_error, - d->errorMessage }; -} - -QByteArray SshDeviceProcess::readAllStandardOutput() -{ - return d->remoteProcess.get() ? d->remoteProcess->readAllStandardOutput() : QByteArray(); -} - -QByteArray SshDeviceProcess::readAllStandardError() -{ - return d->remoteProcess.get() ? d->remoteProcess->readAllStandardError() : QByteArray(); -} - -void SshDeviceProcess::handleConnected() -{ - QTC_ASSERT(d->state == SshDeviceProcessPrivate::Connecting, return); - d->setState(SshDeviceProcessPrivate::Connected); - - d->remoteProcess = usesTerminal() && d->processName.isEmpty() - ? d->connection->createRemoteShell() - : d->connection->createRemoteProcess(fullCommandLine()); - const QString display = d->displayName; - if (!display.isEmpty()) - d->remoteProcess->requestX11Forwarding(display); - if (usesTerminal()) { - setAbortOnMetaChars(false); - setCommand(d->remoteProcess->fullLocalCommandLine(true)); - QtcProcess::startImpl(); - } else { - connect(d->remoteProcess.get(), &QtcProcess::started, - this, &SshDeviceProcess::handleProcessStarted); - connect(d->remoteProcess.get(), &QtcProcess::done, this, [this] { - handleProcessFinished(d->remoteProcess->errorString()); - emit done(); - }); - connect(d->remoteProcess.get(), &QtcProcess::readyReadStandardOutput, - this, &QtcProcess::readyReadStandardOutput); - connect(d->remoteProcess.get(), &QtcProcess::readyReadStandardError, - this, &QtcProcess::readyReadStandardError); - d->remoteProcess->start(); - } -} - -void SshDeviceProcess::handleConnectionError() -{ - QTC_ASSERT(d->state != SshDeviceProcessPrivate::Inactive, return); - - d->errorMessage = d->connection->errorString(); - handleDisconnected(); -} - -void SshDeviceProcess::handleDisconnected() -{ - QTC_ASSERT(d->state != SshDeviceProcessPrivate::Inactive, return); - const SshDeviceProcessPrivate::State oldState = d->state; - d->setState(SshDeviceProcessPrivate::Inactive); - switch (oldState) { - case SshDeviceProcessPrivate::Connecting: - case SshDeviceProcessPrivate::Connected: - emit errorOccurred(QProcess::FailedToStart); - emit done(); - break; - case SshDeviceProcessPrivate::ProcessRunning: - d->exitStatus = QProcess::CrashExit; - emit finished(); - emit done(); - default: - break; - } -} - -void SshDeviceProcess::handleProcessStarted() -{ - QTC_ASSERT(d->state == SshDeviceProcessPrivate::Connected, return); - - d->setState(SshDeviceProcessPrivate::ProcessRunning); - emit started(); -} - -void SshDeviceProcess::handleProcessFinished(const QString &error) -{ - d->errorMessage = error; - if (d->killOperation && error.isEmpty()) - d->errorMessage = tr("The process was ended forcefully."); - d->setState(SshDeviceProcessPrivate::Inactive); - emit finished(); -} - -void SshDeviceProcess::handleKillOperationFinished(const QString &errorMessage) -{ - QTC_ASSERT(d->state == SshDeviceProcessPrivate::ProcessRunning, return); - if (errorMessage.isEmpty()) // Process will finish as expected; nothing to do here. - return; - - d->exitStatus = QProcess::CrashExit; // Not entirely true, but it will get the message across. - d->errorMessage = tr("Failed to kill remote process: %1").arg(errorMessage); - d->setState(SshDeviceProcessPrivate::Inactive); - emit finished(); - emit done(); -} - -void SshDeviceProcess::handleKillOperationTimeout() -{ - d->exitStatus = QProcess::CrashExit; // Not entirely true, but it will get the message across. - d->errorMessage = tr("Timeout waiting for remote process to finish."); - d->setState(SshDeviceProcessPrivate::Inactive); - emit finished(); - emit done(); -} - -QString SshDeviceProcess::fullCommandLine() const -{ - return commandLine().toUserOutput(); -} - -void SshDeviceProcess::SshDeviceProcessPrivate::doSignal(Signal signal) -{ - if (processName.isEmpty()) - return; - switch (state) { - case SshDeviceProcessPrivate::Inactive: - QTC_ASSERT(false, return); - break; - case SshDeviceProcessPrivate::Connecting: - errorMessage = tr("Terminated by request."); - setState(SshDeviceProcessPrivate::Inactive); - emit q->errorOccurred(QProcess::FailedToStart); - emit q->done(); - break; - case SshDeviceProcessPrivate::Connected: - case SshDeviceProcessPrivate::ProcessRunning: - DeviceProcessSignalOperation::Ptr signalOperation = m_device->signalOperation(); - const qint64 processId = q->processId(); - if (signal == Signal::Interrupt) { - if (processId != 0) - signalOperation->interruptProcess(processId); - else - signalOperation->interruptProcess(processName); - } else { - if (killOperation) // We are already in the process of killing the app. - return; - killOperation = signalOperation; - connect(signalOperation.data(), &DeviceProcessSignalOperation::finished, q, - &SshDeviceProcess::handleKillOperationFinished); - killTimer.start(5000); - if (processId != 0) - signalOperation->killProcess(processId); - else - signalOperation->killProcess(processName); - } - break; - } -} - -void SshDeviceProcess::SshDeviceProcessPrivate::setState(SshDeviceProcess::SshDeviceProcessPrivate::State newState) -{ - if (state == newState) - return; - - state = newState; - if (state != Inactive) - return; - - if (killOperation) { - killOperation->disconnect(q); - killOperation.clear(); - if (q->usesTerminal()) - QMetaObject::invokeMethod(q, &QtcProcess::stopProcess, Qt::QueuedConnection); - } - killTimer.stop(); - if (remoteProcess) - remoteProcess->disconnect(q); - if (connection) { - connection->disconnect(q); - QSsh::SshConnectionManager::releaseConnection(connection); - connection = nullptr; - } -} - -qint64 SshDeviceProcess::write(const QString &data) -{ - QTC_ASSERT(!usesTerminal(), return -1); - return d->remoteProcess->write(data); -} - -} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h deleted file mode 100644 index 4a48f35e9d5..00000000000 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h +++ /dev/null @@ -1,79 +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 "../projectexplorer_export.h" - -#include - -#include - -namespace ProjectExplorer { - -class IDevice; - -class PROJECTEXPLORER_EXPORT SshDeviceProcess : public Utils::QtcProcess -{ - Q_OBJECT -public: - explicit SshDeviceProcess(const QSharedPointer &device, QObject *parent = nullptr); - ~SshDeviceProcess() override; - - void startImpl() override; - void interrupt() override; - void terminate() override; - void kill() override; - - Utils::ProcessResultData resultData() const override; - - QByteArray readAllStandardOutput() override; - QByteArray readAllStandardError() override; - - qint64 write(const QString &data) override; - -protected: - void emitStarted() override; - void emitFinished() override; - - const QSharedPointer &device() const; - -private: - void handleConnected(); - void handleConnectionError(); - void handleDisconnected(); - void handleProcessStarted(); - void handleProcessFinished(const QString &error); - void handleKillOperationFinished(const QString &errorMessage); - void handleKillOperationTimeout(); - - virtual QString fullCommandLine() const; - - class SshDeviceProcessPrivate; - friend class SshDeviceProcessPrivate; - const std::unique_ptr d; -}; - -} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs index f699892fa91..2a75a32738c 100644 --- a/src/plugins/projectexplorer/projectexplorer.qbs +++ b/src/plugins/projectexplorer/projectexplorer.qbs @@ -224,7 +224,6 @@ Project { "idevicefwd.h", "idevicewidget.h", "localprocesslist.cpp", "localprocesslist.h", - "sshdeviceprocess.cpp", "sshdeviceprocess.h", "sshdeviceprocesslist.cpp", "sshdeviceprocesslist.h", "sshsettingspage.cpp", "sshsettingspage.h", "desktopprocesssignaloperation.cpp", "desktopprocesssignaloperation.h" diff --git a/src/plugins/qnx/CMakeLists.txt b/src/plugins/qnx/CMakeLists.txt index 5e2e2934cb8..98d3ed92d2d 100644 --- a/src/plugins/qnx/CMakeLists.txt +++ b/src/plugins/qnx/CMakeLists.txt @@ -11,7 +11,6 @@ add_qtc_plugin(Qnx qnxdebugsupport.cpp qnxdebugsupport.h qnxdeployqtlibrariesdialog.cpp qnxdeployqtlibrariesdialog.h qnxdeployqtlibrariesdialog.ui qnxdevice.cpp qnxdevice.h - qnxdeviceprocess.cpp qnxdeviceprocess.h qnxdeviceprocesslist.cpp qnxdeviceprocesslist.h qnxdeviceprocesssignaloperation.cpp qnxdeviceprocesssignaloperation.h qnxdevicetester.cpp qnxdevicetester.h diff --git a/src/plugins/qnx/qnx.qbs b/src/plugins/qnx/qnx.qbs index b4b3aeede17..8cdc6034bc4 100644 --- a/src/plugins/qnx/qnx.qbs +++ b/src/plugins/qnx/qnx.qbs @@ -36,8 +36,6 @@ QtcPlugin { "qnxdeviceprocesslist.h", "qnxdeviceprocesssignaloperation.cpp", "qnxdeviceprocesssignaloperation.h", - "qnxdeviceprocess.cpp", - "qnxdeviceprocess.h", "qnxdevicetester.cpp", "qnxdevicetester.h", "qnxsettingswidget.ui", diff --git a/src/plugins/qnx/qnxdevice.cpp b/src/plugins/qnx/qnxdevice.cpp index bab19596699..7830e9c29f2 100644 --- a/src/plugins/qnx/qnxdevice.cpp +++ b/src/plugins/qnx/qnxdevice.cpp @@ -30,7 +30,6 @@ #include "qnxdeviceprocesslist.h" #include "qnxdeviceprocesssignaloperation.h" #include "qnxdeployqtlibrariesdialog.h" -#include "qnxdeviceprocess.h" #include "qnxdevicewizard.h" #include @@ -197,11 +196,6 @@ DeviceTester *QnxDevice::createDeviceTester() const return new QnxDeviceTester; } -QtcProcess *QnxDevice::createProcess(QObject *parent) const -{ - return new QnxDeviceProcess(sharedFromThis(), parent); -} - Utils::ProcessInterface *QnxDevice::createProcessInterface() const { return new QnxProcessImpl(this); diff --git a/src/plugins/qnx/qnxdevice.h b/src/plugins/qnx/qnxdevice.h index f537ffdec97..07266e2ff91 100644 --- a/src/plugins/qnx/qnxdevice.h +++ b/src/plugins/qnx/qnxdevice.h @@ -47,7 +47,6 @@ public: ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override; ProjectExplorer::DeviceTester *createDeviceTester() const override; - Utils::QtcProcess *createProcess(QObject *parent) const override; Utils::ProcessInterface *createProcessInterface() const override; int qnxVersion() const; diff --git a/src/plugins/qnx/qnxdeviceprocess.cpp b/src/plugins/qnx/qnxdeviceprocess.cpp deleted file mode 100644 index 3236ba62d24..00000000000 --- a/src/plugins/qnx/qnxdeviceprocess.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 BlackBerry Limited. All rights reserved. -** Contact: KDAB (info@kdab.com) -** -** 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 "qnxdeviceprocess.h" - -#include -#include - -#include - -using namespace ProjectExplorer; -using namespace Utils; - -namespace Qnx { -namespace Internal { - -static int pidFileCounter = 0; - -QnxDeviceProcess::QnxDeviceProcess(const QSharedPointer &device, QObject *parent) - : SshDeviceProcess(device, parent) -{ - m_pidFile = QString::fromLatin1("/var/run/qtc.%1.pid").arg(++pidFileCounter); -} - -QString QnxDeviceProcess::fullCommandLine() const -{ - const CommandLine command = commandLine(); - QStringList args = ProcessArgs::splitArgs(command.arguments()); - args.prepend(command.executable().toString()); - QString cmd = ProcessArgs::createUnixArgs(args).toString(); - - QString fullCommandLine = - "test -f /etc/profile && . /etc/profile ; " - "test -f $HOME/profile && . $HOME/profile ; "; - - if (!workingDirectory().isEmpty()) - fullCommandLine += QString::fromLatin1("cd %1 ; ").arg( - ProcessArgs::quoteArg(workingDirectory().toString())); - - const Environment env = remoteEnvironment(); - for (auto it = env.constBegin(); it != env.constEnd(); ++it) { - fullCommandLine += QString::fromLatin1("%1='%2' ") - .arg(env.key(it)).arg(env.expandedValueForKey(env.key(it))); - } - - fullCommandLine += QString::fromLatin1("%1 & echo $! > %2").arg(cmd).arg(m_pidFile); - - return fullCommandLine; -} - -void QnxDeviceProcess::doSignal(int sig) -{ - auto signaler = new SshDeviceProcess(device(), this); - const QString args = QString("-%2 `cat %1`").arg(m_pidFile).arg(sig); - signaler->setCommand({"kill", args, CommandLine::Raw}); - connect(signaler, &SshDeviceProcess::finished, signaler, &QObject::deleteLater); - signaler->start(); -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/qnxdeviceprocess.h b/src/plugins/qnx/qnxdeviceprocess.h deleted file mode 100644 index bcbf386bff4..00000000000 --- a/src/plugins/qnx/qnxdeviceprocess.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 BlackBerry Limited. All rights reserved. -** Contact: KDAB (info@kdab.com) -** -** 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 "qnx_export.h" - -#include - -namespace Qnx { -namespace Internal { - -class QnxDeviceProcess : public ProjectExplorer::SshDeviceProcess -{ -public: - QnxDeviceProcess(const QSharedPointer &device, QObject *parent); - - void interrupt() override { doSignal(2); } - void terminate() override { doSignal(15); } - void kill() override { doSignal(9); } - QString fullCommandLine() const override; - -private: - void doSignal(int sig); - QString m_pidFile; -}; - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/remotelinux/CMakeLists.txt b/src/plugins/remotelinux/CMakeLists.txt index 2cf54a68ef0..2992fbff1da 100644 --- a/src/plugins/remotelinux/CMakeLists.txt +++ b/src/plugins/remotelinux/CMakeLists.txt @@ -14,7 +14,6 @@ add_qtc_plugin(RemoteLinux genericlinuxdeviceconfigurationwizardpages.cpp genericlinuxdeviceconfigurationwizardpages.h genericlinuxdeviceconfigurationwizardsetuppage.ui linuxdevice.cpp linuxdevice.h - linuxdeviceprocess.cpp linuxdeviceprocess.h linuxdevicetester.cpp linuxdevicetester.h linuxprocessinterface.h makeinstallstep.cpp makeinstallstep.h diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp index 7ac0096d78e..8aaef841f84 100644 --- a/src/plugins/remotelinux/linuxdevice.cpp +++ b/src/plugins/remotelinux/linuxdevice.cpp @@ -27,7 +27,6 @@ #include "genericlinuxdeviceconfigurationwidget.h" #include "genericlinuxdeviceconfigurationwizard.h" -#include "linuxdeviceprocess.h" #include "linuxdevicetester.h" #include "linuxprocessinterface.h" #include "publickeydeploymentdialog.h" @@ -1034,11 +1033,6 @@ IDeviceWidget *LinuxDevice::createWidget() return new GenericLinuxDeviceConfigurationWidget(sharedFromThis()); } -QtcProcess *LinuxDevice::createProcess(QObject *parent) const -{ - return new LinuxDeviceProcess(sharedFromThis(), parent); -} - bool LinuxDevice::canAutoDetectPorts() const { return true; diff --git a/src/plugins/remotelinux/linuxdevice.h b/src/plugins/remotelinux/linuxdevice.h index af3baeb22bd..176aa6f1074 100644 --- a/src/plugins/remotelinux/linuxdevice.h +++ b/src/plugins/remotelinux/linuxdevice.h @@ -46,8 +46,6 @@ public: ProjectExplorer::IDeviceWidget *createWidget() override; - bool canCreateProcess() const override { return true; } - Utils::QtcProcess *createProcess(QObject *parent) const override; bool canAutoDetectPorts() const override; ProjectExplorer::PortsGatheringMethod::Ptr portsGatheringMethod() const override; bool canCreateProcessModel() const override { return true; } diff --git a/src/plugins/remotelinux/linuxdeviceprocess.cpp b/src/plugins/remotelinux/linuxdeviceprocess.cpp deleted file mode 100644 index 4b3d2c39e99..00000000000 --- a/src/plugins/remotelinux/linuxdeviceprocess.cpp +++ /dev/null @@ -1,114 +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 "linuxdeviceprocess.h" - -#include - -#include - -using namespace ProjectExplorer; -using namespace Utils; - -namespace RemoteLinux { - -const QByteArray pidMarker = "__qtc"; - -LinuxDeviceProcess::LinuxDeviceProcess(const QSharedPointer &device, - QObject *parent) - : ProjectExplorer::SshDeviceProcess(device, parent) -{ - connect(this, &QtcProcess::finished, this, [this]() { - m_processId = 0; - }); - connect(this, &QtcProcess::started, this, [this]() { - m_pidParsed = false; - m_output.clear(); - }); -} - -QByteArray LinuxDeviceProcess::readAllStandardOutput() -{ - QByteArray output = SshDeviceProcess::readAllStandardOutput(); - if (m_pidParsed || usesTerminal()) - return output; - - m_output.append(output); - static const QByteArray endMarker = pidMarker + '\n'; - const int endMarkerOffset = m_output.indexOf(endMarker); - if (endMarkerOffset == -1) - return {}; - const int startMarkerOffset = m_output.indexOf(pidMarker); - if (startMarkerOffset == endMarkerOffset) // Only theoretically possible. - return {}; - const int pidStart = startMarkerOffset + pidMarker.length(); - const QByteArray pidString = m_output.mid(pidStart, endMarkerOffset - pidStart); - m_pidParsed = true; - m_processId = pidString.toLongLong(); - - // We don't want to show output from e.g. /etc/profile. - const QByteArray actualOutput = m_output.mid(endMarkerOffset + endMarker.length()); - m_output.clear(); - return actualOutput; -} - -qint64 LinuxDeviceProcess::processId() const -{ - return m_processId < 0 ? 0 : m_processId; -} - -QString LinuxDeviceProcess::fullCommandLine() const -{ - CommandLine cmd; - - const QStringList rcFilesToSource = {"/etc/profile", "$HOME/.profile"}; - for (const QString &filePath : rcFilesToSource) { - cmd.addArgs({"test", "-f", filePath}); - cmd.addArgs("&&", CommandLine::Raw); - cmd.addArgs({".", filePath}); - cmd.addArgs(";", CommandLine::Raw); - } - - if (!workingDirectory().isEmpty()) { - cmd.addArgs({"cd", workingDirectory().path()}); - cmd.addArgs("&&", CommandLine::Raw); - } - - if (!usesTerminal()) - cmd.addArgs(QString("echo ") + pidMarker + "$$" + pidMarker + " && ", CommandLine::Raw); - - const Environment &env = remoteEnvironment(); - for (auto it = env.constBegin(); it != env.constEnd(); ++it) - cmd.addArgs(env.key(it) + "='" + env.expandedValueForKey(env.key(it)) + '\'', CommandLine::Raw); - - if (!usesTerminal()) - cmd.addArg("exec"); - - cmd.addCommandLineAsArgs(commandLine(), CommandLine::Raw); - - return cmd.arguments(); -} - -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/linuxdeviceprocess.h b/src/plugins/remotelinux/linuxdeviceprocess.h deleted file mode 100644 index 2faefd2bdb1..00000000000 --- a/src/plugins/remotelinux/linuxdeviceprocess.h +++ /dev/null @@ -1,52 +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 - -namespace RemoteLinux { - -class REMOTELINUX_EXPORT LinuxDeviceProcess : public ProjectExplorer::SshDeviceProcess -{ - Q_OBJECT -public: - explicit LinuxDeviceProcess(const QSharedPointer &device, - QObject *parent = nullptr); - - QByteArray readAllStandardOutput() override; - -private: - QString fullCommandLine() const override; - qint64 processId() const override; - - QByteArray m_output; - qint64 m_processId = 0; - bool m_pidParsed = false; -}; - -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/remotelinux.qbs b/src/plugins/remotelinux/remotelinux.qbs index f0330c04de4..b08469ecab1 100644 --- a/src/plugins/remotelinux/remotelinux.qbs +++ b/src/plugins/remotelinux/remotelinux.qbs @@ -38,8 +38,6 @@ Project { "genericlinuxdeviceconfigurationwizardsetuppage.ui", "linuxdevice.cpp", "linuxdevice.h", - "linuxdeviceprocess.cpp", - "linuxdeviceprocess.h", "linuxdevicetester.cpp", "linuxdevicetester.h", "linuxprocessinterface.h",