DeviceProcess: Minimize the usage of DeviceProcess

DeviceProcess doesn't provide any public API, so
replace all usages of it with QtcProcess.
Keep using DeviceProcess only for reimplementations.

Change-Id: I35a14251a81dd0dde426f56ca2e809b527cc863c
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-02-28 12:25:26 +01:00
parent e327007bd8
commit 8af62eb256
28 changed files with 70 additions and 75 deletions

View File

@@ -167,7 +167,7 @@ ProjectExplorer::IDeviceWidget *QdbDevice::createWidget()
return w;
}
ProjectExplorer::DeviceProcess *QdbDevice::createProcess(QObject *parent) const
QtcProcess *QdbDevice::createProcess(QObject *parent) const
{
return new QdbDeviceProcess(sharedFromThis(), parent);
}

View File

@@ -44,7 +44,7 @@ public:
ProjectExplorer::IDeviceWidget *createWidget() final;
ProjectExplorer::DeviceProcess *createProcess(QObject *parent) const final;
Utils::QtcProcess *createProcess(QObject *parent) const final;
void setSerialNumber(const QString &serial);
QString serialNumber() const;

View File

@@ -54,7 +54,6 @@
#include <coreplugin/icore.h>
#include <coreplugin/messagebox.h>
#include <projectexplorer/devicesupport/deviceprocess.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/taskhub.h>

View File

@@ -121,10 +121,10 @@ void DockerDeviceProcess::start()
DockerDevice::ConstPtr dockerDevice = qSharedPointerCast<const DockerDevice>(device());
QTC_ASSERT(dockerDevice, return);
connect(this, &DeviceProcess::readyReadStandardOutput, this, [this] {
connect(this, &QtcProcess::readyReadStandardOutput, this, [this] {
MessageManager::writeSilently(QString::fromLocal8Bit(readAllStandardError()));
});
connect(this, &DeviceProcess::readyReadStandardError, this, [this] {
connect(this, &QtcProcess::readyReadStandardError, this, [this] {
MessageManager::writeDisrupting(QString::fromLocal8Bit(readAllStandardError()));
});
@@ -495,7 +495,7 @@ DockerDevice::DockerDevice(const DockerDeviceData &data)
QObject::connect(proc, &QtcProcess::finished, proc, &QObject::deleteLater);
QObject::connect(proc, &DeviceProcess::errorOccurred, [proc] {
QObject::connect(proc, &QtcProcess::errorOccurred, [proc] {
MessageManager::writeDisrupting(tr("Error starting remote shell."));
proc->deleteLater();
});
@@ -938,7 +938,7 @@ QVariantMap DockerDevice::toMap() const
return map;
}
DeviceProcess *DockerDevice::createProcess(QObject *parent) const
QtcProcess *DockerDevice::createProcess(QObject *parent) const
{
return new DockerDeviceProcess(sharedFromThis(), parent);
}

View File

@@ -66,7 +66,7 @@ public:
QList<ProjectExplorer::Task> validate() const override;
bool canCreateProcess() const override { return true; }
ProjectExplorer::DeviceProcess *createProcess(QObject *parent) const override;
Utils::QtcProcess *createProcess(QObject *parent) const override;
bool canAutoDetectPorts() const override;
ProjectExplorer::PortsGatheringMethod::Ptr portsGatheringMethod() const override;
bool canCreateProcessModel() const override { return false; }

View File

@@ -26,7 +26,6 @@
#include "mcusupportdevice.h"
#include "mcusupportconstants.h"
#include <projectexplorer/devicesupport/deviceprocess.h>
#include <projectexplorer/runcontrol.h>
using namespace ProjectExplorer;

View File

@@ -33,6 +33,7 @@
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/taskhub.h>
#include <utils/qtcprocess.h>
#include <utils/stringutils.h>
#include <QLoggingCategory>

View File

@@ -27,9 +27,6 @@
#include "exewrappers/mesonwrapper.h"
#include <utils/qtcprocess.h>
#include <QBuffer>
#include <QByteArray>
#include <QElapsedTimer>
#include <QFutureInterface>
@@ -39,6 +36,8 @@
#include <memory>
namespace Utils { class QtcProcess; }
namespace MesonProjectManager {
namespace Internal {

View File

@@ -29,7 +29,6 @@
#include <coreplugin/messagebox.h>
#include <projectexplorer/devicesupport/deviceprocess.h>
#include <projectexplorer/kit.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/runcontrol.h>
@@ -43,7 +42,9 @@
#include <QHeaderView>
#include <QMessageBox>
#include <QMetaEnum>
#include <QPushButton>
#include <QStyledItemDelegate>
#include <QTableView>
using namespace Utils;
@@ -124,6 +125,8 @@ PerfConfigWidget::PerfConfigWidget(PerfSettings *settings, QWidget *parent)
}.attachTo(this);
}
PerfConfigWidget::~PerfConfigWidget() = default;
void PerfConfigWidget::setTarget(ProjectExplorer::Target *target)
{
ProjectExplorer::IDevice::ConstPtr device;
@@ -146,10 +149,10 @@ void PerfConfigWidget::setTarget(ProjectExplorer::Target *target)
return;
}
connect(m_process.get(), &ProjectExplorer::DeviceProcess::finished,
connect(m_process.get(), &QtcProcess::finished,
this, &PerfConfigWidget::handleProcessFinished);
connect(m_process.get(), &ProjectExplorer::DeviceProcess::errorOccurred,
connect(m_process.get(), &QtcProcess::errorOccurred,
this, &PerfConfigWidget::handleProcessError);
useTracePointsButton->setEnabled(true);

View File

@@ -29,10 +29,14 @@
#include <coreplugin/dialogs/ioptionspage.h>
#include <projectexplorer/devicesupport/deviceprocess.h>
#include <QProcess>
#include <QPushButton>
#include <QTableView>
QT_BEGIN_NAMESPACE
class QPushButton;
class QTableView;
QT_END_NAMESPACE
namespace Utils { class QtcProcess; }
namespace PerfProfiler {
namespace Internal {
@@ -42,6 +46,7 @@ class PerfConfigWidget : public Core::IOptionsPageWidget
Q_OBJECT
public:
explicit PerfConfigWidget(PerfSettings *settings, QWidget *parent = nullptr);
~PerfConfigWidget();
void updateUi();
void setTarget(ProjectExplorer::Target *target);
@@ -55,7 +60,7 @@ private:
void handleProcessError(QProcess::ProcessError error);
PerfSettings *m_settings;
std::unique_ptr<ProjectExplorer::DeviceProcess> m_process;
std::unique_ptr<Utils::QtcProcess> m_process;
QTableView *eventsView;
QPushButton *useTracePointsButton;

View File

@@ -32,7 +32,6 @@
#include <coreplugin/icore.h>
#include <coreplugin/messagemanager.h>
#include <projectexplorer/devicesupport/deviceprocess.h>
#include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/target.h>
@@ -131,9 +130,9 @@ public:
return;
}
connect(m_process, &DeviceProcess::started, this, &RunWorker::reportStarted);
connect(m_process, &DeviceProcess::finished, this, &RunWorker::reportStopped);
connect(m_process, &DeviceProcess::errorOccurred, [this](QProcess::ProcessError e) {
connect(m_process, &QtcProcess::started, this, &RunWorker::reportStarted);
connect(m_process, &QtcProcess::finished, this, &RunWorker::reportStopped);
connect(m_process, &QtcProcess::errorOccurred, [this](QProcess::ProcessError e) {
// The terminate() below will frequently lead to QProcess::Crashed. We're not interested
// in that. FailedToStart is the only actual failure.
if (e == QProcess::FailedToStart) {
@@ -162,10 +161,10 @@ public:
m_process->terminate();
}
DeviceProcess *recorder() { return m_process; }
QtcProcess *recorder() { return m_process; }
private:
QPointer<DeviceProcess> m_process;
QPointer<QtcProcess> m_process;
QStringList m_perfRecordArguments;
};
@@ -214,12 +213,12 @@ void PerfProfilerRunner::start()
PerfDataReader *reader = m_perfParserWorker->reader();
if (auto prw = qobject_cast<LocalPerfRecordWorker *>(m_perfRecordWorker)) {
// That's the local case.
DeviceProcess *recorder = prw->recorder();
connect(recorder, &DeviceProcess::readyReadStandardError, this, [this, recorder] {
QtcProcess *recorder = prw->recorder();
connect(recorder, &QtcProcess::readyReadStandardError, this, [this, recorder] {
appendMessage(QString::fromLocal8Bit(recorder->readAllStandardError()),
Utils::StdErrFormat);
});
connect(recorder, &DeviceProcess::readyReadStandardOutput, this, [this, reader, recorder] {
connect(recorder, &QtcProcess::readyReadStandardOutput, this, [this, reader, recorder] {
if (!reader->feedParser(recorder->readAllStandardOutput()))
reportFailure(tr("Failed to transfer Perf data to perfparser."));
});

View File

@@ -35,9 +35,8 @@
#include <projectexplorer/target.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QTimer>
@@ -84,8 +83,8 @@ PerfTracePointDialog::PerfTracePointDialog() :
PerfTracePointDialog::~PerfTracePointDialog()
{
if (m_process && m_process->state() != QProcess::NotRunning) {
DeviceProcess *process = m_process.release();
connect(process, &DeviceProcess::finished, process, &QObject::deleteLater);
QtcProcess *process = m_process.release();
connect(process, &QtcProcess::finished, process, &QObject::deleteLater);
process->kill();
QTimer::singleShot(10000, process, &QObject::deleteLater);
}
@@ -108,10 +107,10 @@ void PerfTracePointDialog::runScript()
else
m_process->setCommand({"sh", {}});
connect(m_process.get(), &DeviceProcess::finished,
connect(m_process.get(), &QtcProcess::finished,
this, &PerfTracePointDialog::handleProcessFinished);
connect(m_process.get(), &DeviceProcess::errorOccurred,
connect(m_process.get(), &QtcProcess::errorOccurred,
this, &PerfTracePointDialog::handleProcessError);
m_process->start();

View File

@@ -25,14 +25,10 @@
#pragma once
#include <projectexplorer/devicesupport/deviceprocess.h>
#include <projectexplorer/devicesupport/idevice.h>
#include <QDialog>
#include <QTextEdit>
#include <QLabel>
#include <QDialogButtonBox>
#include <QComboBox>
#include <QProcess>
namespace PerfProfiler {
namespace Internal {
@@ -55,7 +51,7 @@ private:
Ui::PerfTracePointDialog *m_ui;
ProjectExplorer::IDevice::ConstPtr m_device;
std::unique_ptr<ProjectExplorer::DeviceProcess> m_process;
std::unique_ptr<Utils::QtcProcess> m_process;
void accept() final;
void reject() final;

View File

@@ -36,7 +36,6 @@
#include <utils/qtcprocess.h>
#include "devicesupport/desktopdevice.h"
#include "devicesupport/deviceprocess.h"
#include "projectexplorer.h"
#include "projectexplorersettings.h"
#include "runcontrol.h"

View File

@@ -97,7 +97,7 @@ DeviceProcessList *DesktopDevice::createProcessListModel(QObject *parent) const
return new Internal::LocalProcessList(sharedFromThis(), parent);
}
DeviceProcess *DesktopDevice::createProcess(QObject *parent) const
QtcProcess *DesktopDevice::createProcess(QObject *parent) const
{
return new Internal::DesktopDeviceProcess(sharedFromThis(), parent);
}

View File

@@ -50,7 +50,7 @@ public:
DeviceProcessList *createProcessListModel(QObject *parent) const override;
bool canCreateProcess() const override { return true; }
ProjectExplorer::PortsGatheringMethod::Ptr portsGatheringMethod() const override;
DeviceProcess *createProcess(QObject *parent) 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;

View File

@@ -23,7 +23,6 @@
**
****************************************************************************/
#include "deviceprocess.h"
#include "deviceusedportsgatherer.h"
#include <ssh/sshconnection.h>
@@ -31,6 +30,7 @@
#include <utils/port.h>
#include <utils/portlist.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <utils/url.h>
#include <QPointer>
@@ -44,7 +44,7 @@ namespace Internal {
class DeviceUsedPortsGathererPrivate
{
public:
QPointer<DeviceProcess> process;
QPointer<QtcProcess> process;
QList<Port> usedPorts;
QByteArray remoteStdout;
QByteArray remoteStderr;
@@ -77,13 +77,13 @@ void DeviceUsedPortsGatherer::start(const IDevice::ConstPtr &device)
const QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::AnyIPProtocol;
d->process = d->device->createProcess(this);
connect(d->process.data(), &DeviceProcess::finished,
connect(d->process.data(), &QtcProcess::finished,
this, &DeviceUsedPortsGatherer::handleProcessFinished);
connect(d->process.data(), &DeviceProcess::errorOccurred,
connect(d->process.data(), &QtcProcess::errorOccurred,
this, &DeviceUsedPortsGatherer::handleProcessError);
connect(d->process.data(), &DeviceProcess::readyReadStandardOutput,
connect(d->process.data(), &QtcProcess::readyReadStandardOutput,
this, &DeviceUsedPortsGatherer::handleRemoteStdOut);
connect(d->process.data(), &DeviceProcess::readyReadStandardError,
connect(d->process.data(), &QtcProcess::readyReadStandardError,
this, &DeviceUsedPortsGatherer::handleRemoteStdErr);
d->process->setCommand(d->portsGatheringMethod->commandLine(protocol));

View File

@@ -590,7 +590,7 @@ OsType IDevice::osType() const
return d->osType;
}
DeviceProcess *IDevice::createProcess(QObject * /* parent */) const
QtcProcess *IDevice::createProcess(QObject * /* parent */) const
{
QTC_CHECK(false);
return nullptr;

View File

@@ -60,7 +60,6 @@ class QtcProcess;
namespace ProjectExplorer {
class DeviceProcess;
class DeviceProcessList;
class Kit;
class Task;
@@ -182,7 +181,7 @@ public:
virtual DeviceTester *createDeviceTester() const;
virtual bool canCreateProcess() const { return false; }
virtual DeviceProcess *createProcess(QObject *parent) const;
virtual Utils::QtcProcess *createProcess(QObject *parent) const;
virtual DeviceProcessSignalOperation::Ptr signalOperation() const = 0;
virtual DeviceEnvironmentFetcher::Ptr environmentFetcher() const;

View File

@@ -101,8 +101,8 @@ void QnxDevice::updateVersionNumber() const
{
QEventLoop eventLoop;
SshDeviceProcess versionNumberProcess(sharedFromThis());
QObject::connect(&versionNumberProcess, &SshDeviceProcess::finished, &eventLoop, &QEventLoop::quit);
QObject::connect(&versionNumberProcess, &DeviceProcess::errorOccurred, &eventLoop, &QEventLoop::quit);
QObject::connect(&versionNumberProcess, &QtcProcess::finished, &eventLoop, &QEventLoop::quit);
QObject::connect(&versionNumberProcess, &QtcProcess::errorOccurred, &eventLoop, &QEventLoop::quit);
versionNumberProcess.setCommand({"uname", {"-r"}});
versionNumberProcess.start();
@@ -156,7 +156,7 @@ DeviceTester *QnxDevice::createDeviceTester() const
return new QnxDeviceTester;
}
DeviceProcess *QnxDevice::createProcess(QObject *parent) const
QtcProcess *QnxDevice::createProcess(QObject *parent) const
{
return new QnxDeviceProcess(sharedFromThis(), parent);
}

View File

@@ -47,7 +47,7 @@ public:
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
ProjectExplorer::DeviceTester *createDeviceTester() const override;
ProjectExplorer::DeviceProcess *createProcess(QObject *parent) const override;
Utils::QtcProcess *createProcess(QObject *parent) const override;
int qnxVersion() const;

View File

@@ -52,15 +52,15 @@ Slog2InfoRunner::Slog2InfoRunner(RunControl *runControl)
m_applicationId.truncate(63);
m_testProcess = new QnxDeviceProcess(device(), this);
connect(m_testProcess, &DeviceProcess::finished, this, &Slog2InfoRunner::handleTestProcessCompleted);
connect(m_testProcess, &QtcProcess::finished, this, &Slog2InfoRunner::handleTestProcessCompleted);
m_launchDateTimeProcess = new SshDeviceProcess(device(), this);
connect(m_launchDateTimeProcess, &DeviceProcess::finished, this, &Slog2InfoRunner::launchSlog2Info);
connect(m_launchDateTimeProcess, &QtcProcess::finished, this, &Slog2InfoRunner::launchSlog2Info);
m_logProcess = new QnxDeviceProcess(device(), this);
connect(m_logProcess, &DeviceProcess::readyReadStandardOutput, this, &Slog2InfoRunner::readLogStandardOutput);
connect(m_logProcess, &DeviceProcess::readyReadStandardError, this, &Slog2InfoRunner::readLogStandardError);
connect(m_logProcess, &DeviceProcess::errorOccurred, this, &Slog2InfoRunner::handleLogError);
connect(m_logProcess, &QtcProcess::readyReadStandardOutput, this, &Slog2InfoRunner::readLogStandardOutput);
connect(m_logProcess, &QtcProcess::readyReadStandardError, this, &Slog2InfoRunner::readLogStandardError);
connect(m_logProcess, &QtcProcess::errorOccurred, this, &Slog2InfoRunner::handleLogError);
}
void Slog2InfoRunner::printMissingWarning()

View File

@@ -317,15 +317,15 @@ LinuxDevice::LinuxDevice()
}});
setOpenTerminal([this](const Environment &env, const FilePath &workingDir) {
DeviceProcess * const proc = createProcess(nullptr);
QObject::connect(proc, &DeviceProcess::finished, [proc] {
QtcProcess * const proc = createProcess(nullptr);
QObject::connect(proc, &QtcProcess::finished, [proc] {
if (!proc->errorString().isEmpty()) {
Core::MessageManager::writeDisrupting(
tr("Error running remote shell: %1").arg(proc->errorString()));
}
proc->deleteLater();
});
QObject::connect(proc, &DeviceProcess::errorOccurred, [proc] {
QObject::connect(proc, &QtcProcess::errorOccurred, [proc] {
Core::MessageManager::writeDisrupting(tr("Error starting remote shell."));
proc->deleteLater();
});
@@ -358,7 +358,7 @@ IDeviceWidget *LinuxDevice::createWidget()
return new GenericLinuxDeviceConfigurationWidget(sharedFromThis());
}
DeviceProcess *LinuxDevice::createProcess(QObject *parent) const
QtcProcess *LinuxDevice::createProcess(QObject *parent) const
{
return new LinuxDeviceProcess(sharedFromThis(), parent);
}

View File

@@ -47,7 +47,7 @@ public:
ProjectExplorer::IDeviceWidget *createWidget() override;
bool canCreateProcess() const override { return true; }
ProjectExplorer::DeviceProcess *createProcess(QObject *parent) const override;
Utils::QtcProcess *createProcess(QObject *parent) const override;
bool canAutoDetectPorts() const override;
ProjectExplorer::PortsGatheringMethod::Ptr portsGatheringMethod() const override;
bool canCreateProcessModel() const override { return true; }

View File

@@ -40,10 +40,10 @@ LinuxDeviceProcess::LinuxDeviceProcess(const QSharedPointer<const ProjectExplore
QObject *parent)
: ProjectExplorer::SshDeviceProcess(device, parent)
{
connect(this, &DeviceProcess::finished, this, [this]() {
connect(this, &QtcProcess::finished, this, [this]() {
m_processId = 0;
});
connect(this, &DeviceProcess::started, this, [this]() {
connect(this, &QtcProcess::started, this, [this]() {
m_pidParsed = false;
m_output.clear();
});

View File

@@ -25,10 +25,10 @@
#include "remotelinuxenvironmentreader.h"
#include <projectexplorer/devicesupport/deviceprocess.h>
#include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/runcontrol.h>
#include <utils/qtcprocess.h>
#include <utils/stringutils.h>
using namespace ProjectExplorer;
@@ -54,9 +54,9 @@ void RemoteLinuxEnvironmentReader::start()
}
m_stop = false;
m_deviceProcess = m_device->createProcess(this);
connect(m_deviceProcess, &DeviceProcess::errorOccurred,
connect(m_deviceProcess, &QtcProcess::errorOccurred,
this, &RemoteLinuxEnvironmentReader::handleError);
connect(m_deviceProcess, &DeviceProcess::finished,
connect(m_deviceProcess, &QtcProcess::finished,
this, &RemoteLinuxEnvironmentReader::remoteProcessFinished);
m_deviceProcess->setCommand({"env", {}});
m_deviceProcess->start();

View File

@@ -30,8 +30,6 @@
#include <QObject>
namespace ProjectExplorer { class DeviceProcess; }
namespace RemoteLinux {
namespace Internal {
@@ -61,7 +59,7 @@ private:
bool m_stop = false;
Utils::Environment m_env;
ProjectExplorer::IDevice::ConstPtr m_device;
ProjectExplorer::DeviceProcess *m_deviceProcess = nullptr;
Utils::QtcProcess *m_deviceProcess = nullptr;
};
} // namespace Internal

View File

@@ -26,7 +26,6 @@
#include "webassemblyconstants.h"
#include "webassemblydevice.h"
#include <projectexplorer/devicesupport/deviceprocess.h>
#include <projectexplorer/runcontrol.h>
using namespace ProjectExplorer;