From d439a7a25fd98535467d1f538ecf47f38ce91a52 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 2 Mar 2022 15:00:31 +0100 Subject: [PATCH] ProjectExplorer: Dissolve DeviceProcess Move remaining device member to subclasses where needed. Change-Id: I1a872315579c7f6529e8937d57511a9e99e06926 Reviewed-by: Jarek Kobus --- src/plugins/docker/dockerdevice.cpp | 12 +++-- src/plugins/projectexplorer/CMakeLists.txt | 1 - .../devicesupport/deviceprocess.cpp | 47 ----------------- .../devicesupport/deviceprocess.h | 52 ------------------- .../devicesupport/sshdeviceprocess.cpp | 13 +++-- .../devicesupport/sshdeviceprocess.h | 8 ++- .../projectexplorer/projectexplorer.qbs | 1 - 7 files changed, 23 insertions(+), 111 deletions(-) delete mode 100644 src/plugins/projectexplorer/devicesupport/deviceprocess.cpp delete mode 100644 src/plugins/projectexplorer/devicesupport/deviceprocess.h diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp index 1f07977c5f5..b0848827634 100644 --- a/src/plugins/docker/dockerdevice.cpp +++ b/src/plugins/docker/dockerdevice.cpp @@ -98,7 +98,7 @@ namespace Internal { static Q_LOGGING_CATEGORY(dockerDeviceLog, "qtc.docker.device", QtWarningMsg); #define LOG(x) qCDebug(dockerDeviceLog) << this << x << '\n' -class DockerDeviceProcess : public ProjectExplorer::DeviceProcess +class DockerDeviceProcess : public Utils::QtcProcess { public: DockerDeviceProcess(const QSharedPointer &device, QObject *parent = nullptr); @@ -106,11 +106,13 @@ public: void start() override; void interrupt() override; + + const QSharedPointer m_device; }; DockerDeviceProcess::DockerDeviceProcess(const QSharedPointer &device, - QObject *parent) - : DeviceProcess(device, parent) + QObject *parent) + : QtcProcess(parent), m_device(device) { setProcessMode(ProcessMode::Writer); } @@ -118,7 +120,7 @@ DockerDeviceProcess::DockerDeviceProcess(const QSharedPointer &de void DockerDeviceProcess::start() { QTC_ASSERT(state() == QProcess::NotRunning, return); - DockerDevice::ConstPtr dockerDevice = qSharedPointerCast(device()); + DockerDevice::ConstPtr dockerDevice = qSharedPointerCast(m_device); QTC_ASSERT(dockerDevice, return); connect(this, &QtcProcess::readyReadStandardOutput, this, [this] { @@ -139,7 +141,7 @@ void DockerDeviceProcess::start() void DockerDeviceProcess::interrupt() { - device()->signalOperation()->interruptProcess(processId()); + m_device->signalOperation()->interruptProcess(processId()); } class DockerPortsGatheringMethod : public PortsGatheringMethod diff --git a/src/plugins/projectexplorer/CMakeLists.txt b/src/plugins/projectexplorer/CMakeLists.txt index 9fe3cee698c..a48c08452b4 100644 --- a/src/plugins/projectexplorer/CMakeLists.txt +++ b/src/plugins/projectexplorer/CMakeLists.txt @@ -54,7 +54,6 @@ add_qtc_plugin(ProjectExplorer devicesupport/devicefactoryselectiondialog.cpp devicesupport/devicefactoryselectiondialog.h devicesupport/devicefactoryselectiondialog.ui devicesupport/devicemanager.cpp devicesupport/devicemanager.h devicesupport/devicemanagermodel.cpp devicesupport/devicemanagermodel.h - devicesupport/deviceprocess.cpp devicesupport/deviceprocess.h devicesupport/deviceprocessesdialog.cpp devicesupport/deviceprocessesdialog.h devicesupport/deviceprocesslist.cpp devicesupport/deviceprocesslist.h devicesupport/devicesettingspage.cpp devicesupport/devicesettingspage.h diff --git a/src/plugins/projectexplorer/devicesupport/deviceprocess.cpp b/src/plugins/projectexplorer/devicesupport/deviceprocess.cpp deleted file mode 100644 index 11e8931bbea..00000000000 --- a/src/plugins/projectexplorer/devicesupport/deviceprocess.cpp +++ /dev/null @@ -1,47 +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 "deviceprocess.h" - -#include "idevice.h" - -#include -#include - -using namespace Utils; - -namespace ProjectExplorer { - -DeviceProcess::DeviceProcess(const IDevice::ConstPtr &device, QObject *parent) - : QtcProcess(parent), m_device(device) -{ -} - -IDevice::ConstPtr DeviceProcess::device() const -{ - return m_device; -} - -} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/devicesupport/deviceprocess.h b/src/plugins/projectexplorer/devicesupport/deviceprocess.h deleted file mode 100644 index 277a2dab1a5..00000000000 --- a/src/plugins/projectexplorer/devicesupport/deviceprocess.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 "../projectexplorer_export.h" - -#include - -#include - -namespace ProjectExplorer { - -class IDevice; - -class PROJECTEXPLORER_EXPORT DeviceProcess : public Utils::QtcProcess -{ - Q_OBJECT - -protected: - explicit DeviceProcess(const QSharedPointer &device, - QObject *parent = nullptr); - - QSharedPointer device() const; - -private: - const QSharedPointer m_device; -}; - -} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp index 8235818121c..d249977338a 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp @@ -51,6 +51,7 @@ public: SshDeviceProcessPrivate(SshDeviceProcess *q) : q(q) {} SshDeviceProcess * const q; + QSharedPointer m_device; QSsh::SshConnection *connection = nullptr; QSsh::SshRemoteProcessPtr remoteProcess; QString processName; @@ -66,9 +67,10 @@ public: }; SshDeviceProcess::SshDeviceProcess(const IDevice::ConstPtr &device, QObject *parent) - : DeviceProcess(device, parent), + : QtcProcess(parent), d(std::make_unique(this)) { + d->m_device = device; connect(&d->killTimer, &QTimer::timeout, this, &SshDeviceProcess::handleKillOperationTimeout); } @@ -82,6 +84,11 @@ void SshDeviceProcess::emitFinished() handleProcessFinished(QtcProcess::errorString()); } +const QSharedPointer &SshDeviceProcess::device() const +{ + return d->m_device; +} + SshDeviceProcess::~SshDeviceProcess() { d->setState(SshDeviceProcessPrivate::Inactive); @@ -98,7 +105,7 @@ void SshDeviceProcess::start() d->processName = commandLine().executable().toString(); d->displayName = extraData("Ssh.X11ForwardToDisplay").toString(); - QSsh::SshConnectionParameters params = device()->sshParameters(); + QSsh::SshConnectionParameters params = d->m_device->sshParameters(); params.x11DisplayName = d->displayName; d->connection = QSsh::SshConnectionManager::acquireConnection(params); connect(d->connection, &QSsh::SshConnection::errorOccurred, @@ -287,7 +294,7 @@ void SshDeviceProcess::SshDeviceProcessPrivate::doSignal(Signal signal) break; case SshDeviceProcessPrivate::Connected: case SshDeviceProcessPrivate::ProcessRunning: - DeviceProcessSignalOperation::Ptr signalOperation = q->device()->signalOperation(); + DeviceProcessSignalOperation::Ptr signalOperation = m_device->signalOperation(); const qint64 processId = q->processId(); if (signal == Signal::Interrupt) { if (processId != 0) diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h index 39f17c55d5e..7ee346d78a4 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h @@ -25,13 +25,15 @@ #pragma once -#include "deviceprocess.h" +#include "idevice.h" + +#include #include namespace ProjectExplorer { -class PROJECTEXPLORER_EXPORT SshDeviceProcess : public DeviceProcess +class PROJECTEXPLORER_EXPORT SshDeviceProcess : public Utils::QtcProcess { Q_OBJECT public: @@ -57,6 +59,8 @@ protected: void emitStarted() override; void emitFinished() override; + const QSharedPointer &device() const; + private: void handleConnected(); void handleConnectionError(); diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs index ffd95ce89d1..1afca928404 100644 --- a/src/plugins/projectexplorer/projectexplorer.qbs +++ b/src/plugins/projectexplorer/projectexplorer.qbs @@ -211,7 +211,6 @@ Project { "devicefactoryselectiondialog.cpp", "devicefactoryselectiondialog.h", "devicefactoryselectiondialog.ui", "devicemanager.cpp", "devicemanager.h", "devicemanagermodel.cpp", "devicemanagermodel.h", - "deviceprocess.cpp", "deviceprocess.h", "deviceprocessesdialog.cpp", "deviceprocessesdialog.h", "deviceprocesslist.cpp", "deviceprocesslist.h", "devicesettingspage.cpp", "devicesettingspage.h",