From f301bb3f973edd9aa500ced20f57acfac5a92933 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 16 May 2022 11:05:17 +0200 Subject: [PATCH 01/12] QtcProcess: Fix behavior of kill() Make it behave more like QProcess::kill(). Before, when QtcProcess::kill() has been called, the process launcher was putting the process into the reaper and notified the QtcProcess that it was already killed, while in fact it could still be alive for a while since it was in reaper's hands. The current fix makes the behavior similar to what QProcess does when calling kill(). So now, in case of a call to kill() the process isn't put into the reaper yet, so it has a chance to report back the finished signal when the process was really stopped. We still use the old behavior of putting the running process into the reaper in case of a call to QtcProcess::close() and when d'tor of QtcProcess was called. We don't report back the confirmation about putting the process into the reaper, since close() is always called from ProcessLauncherImpl d'tor, so there is no one to receive this confirmation anyway. Change-Id: I665e7c8fb1a391dda30c86389259961e715926d6 Reviewed-by: hjk --- src/libs/utils/launcherpackets.h | 5 ++-- src/libs/utils/launchersocket.cpp | 6 ++++ src/libs/utils/launchersocket.h | 1 + src/libs/utils/qtcprocess.cpp | 2 +- .../processlauncher/launchersockethandler.cpp | 29 ++++++------------- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/libs/utils/launcherpackets.h b/src/libs/utils/launcherpackets.h index 896b5a35c5a..2c4dad8d08b 100644 --- a/src/libs/utils/launcherpackets.h +++ b/src/libs/utils/launcherpackets.h @@ -143,8 +143,9 @@ public: StopProcessPacket(quintptr token); enum class SignalType { - Kill, - Terminate + Kill, // Calls QProcess::kill + Terminate, // Calls QProcess::terminate + Close // Puts the process into the reaper, no confirmation signal is being sent. }; SignalType signalType = SignalType::Kill; diff --git a/src/libs/utils/launchersocket.cpp b/src/libs/utils/launchersocket.cpp index 048d118e935..4de1a778d83 100644 --- a/src/libs/utils/launchersocket.cpp +++ b/src/libs/utils/launchersocket.cpp @@ -262,6 +262,12 @@ void CallerHandle::kill() sendStopPacket(StopProcessPacket::SignalType::Kill); } +void CallerHandle::close() +{ + QTC_ASSERT(isCalledFromCallersThread(), return); + sendStopPacket(StopProcessPacket::SignalType::Close); +} + qint64 CallerHandle::processId() const { QTC_ASSERT(isCalledFromCallersThread(), return 0); diff --git a/src/libs/utils/launchersocket.h b/src/libs/utils/launchersocket.h index 1de0585d49a..081cd314659 100644 --- a/src/libs/utils/launchersocket.h +++ b/src/libs/utils/launchersocket.h @@ -89,6 +89,7 @@ public: void sendStopPacket(StopProcessPacket::SignalType signalType); void terminate(); void kill(); + void close(); qint64 processId() const; diff --git a/src/libs/utils/qtcprocess.cpp b/src/libs/utils/qtcprocess.cpp index c8a5f59259f..40ba6a6afbd 100644 --- a/src/libs/utils/qtcprocess.cpp +++ b/src/libs/utils/qtcprocess.cpp @@ -437,7 +437,7 @@ public: } ~ProcessLauncherImpl() final { - m_handle->kill(); + m_handle->close(); LauncherInterface::unregisterHandle(token()); m_handle = nullptr; } diff --git a/src/tools/processlauncher/launchersockethandler.cpp b/src/tools/processlauncher/launchersockethandler.cpp index af9e94d3bf3..321f4688195 100644 --- a/src/tools/processlauncher/launchersockethandler.cpp +++ b/src/tools/processlauncher/launchersockethandler.cpp @@ -242,28 +242,17 @@ void LauncherSocketHandler::handleStopPacket() m_packetParser.token(), m_packetParser.packetData()); - if (packet.signalType == StopProcessPacket::SignalType::Terminate) { + switch (packet.signalType) { + case StopProcessPacket::SignalType::Terminate: process->terminate(); - return; + break; + case StopProcessPacket::SignalType::Kill: + process->kill(); + break; + case StopProcessPacket::SignalType::Close: + removeProcess(process->token()); + break; } - - if (process->state() == QProcess::NotRunning) { - // This shouldn't happen, since as soon as process finishes or error occurrs - // the process is being removed. - logWarn("Got stop request when process was not running"); - } else { - // We got the client request to stop the starting / running process. - // We report process exit to the client. - ProcessDonePacket packet(process->token()); - packet.error = QProcess::Crashed; - packet.exitCode = -1; - packet.exitStatus = QProcess::CrashExit; - if (process->processChannelMode() != QProcess::MergedChannels) - packet.stdErr = process->readAllStandardError(); - packet.stdOut = process->readAllStandardOutput(); - sendPacket(packet); - } - removeProcess(process->token()); } void LauncherSocketHandler::handleShutdownPacket() From ffe1ff2368049459f12470d65148cc436e5d315d Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 1 Jun 2022 12:21:27 +0200 Subject: [PATCH 02/12] GitLab: Fix warning "lambda capture not used" Change-Id: Ife9c83a9cf8302800c9ad14e1e349a7688240717 Reviewed-by: Reviewed-by: Christian Stenger --- src/plugins/gitlab/gitlabplugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/gitlab/gitlabplugin.cpp b/src/plugins/gitlab/gitlabplugin.cpp index 5df45c8e688..9a768c1e663 100644 --- a/src/plugins/gitlab/gitlabplugin.cpp +++ b/src/plugins/gitlab/gitlabplugin.cpp @@ -106,7 +106,7 @@ bool GitLabPlugin::initialize(const QStringList & /*arguments*/, QString * /*err connect(openViewAction, &QAction::triggered, this, &GitLabPlugin::openView); Core::ActionContainer *ac = Core::ActionManager::actionContainer(Core::Constants::M_TOOLS); ac->addAction(gitlabCommand); - connect(&dd->optionsPage, &GitLabOptionsPage::settingsChanged, this, [this] { + connect(&dd->optionsPage, &GitLabOptionsPage::settingsChanged, this, [] { if (dd->dialog) dd->dialog->updateRemotes(); }); From cb2894a51f1529e66d9daf017abe969a25048cb2 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 27 May 2022 10:42:33 +0200 Subject: [PATCH 03/12] EnvironmentWidget: Devirtualize aspect() method The RemoteLinuxEnvironmentAspectWidget subclass was overloading it, however, it was returning the subclass of EnvironmentAspect (i.e. returning RemoteLinuxEnvironmentAspect). Instead, we use the base aspect() method in RemoteLinuxEnvironmentAspectWidget subclass and we cast it into expected RemoteLinuxEnvironmentAspect class. Move some methods into protected section, as they are used only in subclass. Use qobject_cast instead of dynamic_cast inside UploadAndInstallTarPackageStep. Change-Id: Ic3119ca15d46187e0aa7b8b4013e7fc4efec4bd9 Reviewed-by: Reviewed-by: Christian Kandeler --- .../projectexplorer/environmentaspectwidget.cpp | 5 ----- .../projectexplorer/environmentaspectwidget.h | 4 ++-- .../remotelinuxenvironmentaspectwidget.cpp | 12 ++++-------- .../remotelinux/remotelinuxenvironmentaspectwidget.h | 3 +-- .../remotelinux/uploadandinstalltarpackagestep.cpp | 2 +- 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/plugins/projectexplorer/environmentaspectwidget.cpp b/src/plugins/projectexplorer/environmentaspectwidget.cpp index 280cc5ac9da..bb84a49f6a6 100644 --- a/src/plugins/projectexplorer/environmentaspectwidget.cpp +++ b/src/plugins/projectexplorer/environmentaspectwidget.cpp @@ -92,11 +92,6 @@ EnvironmentAspectWidget::EnvironmentAspectWidget(EnvironmentAspect *aspect, QWid this, &EnvironmentAspectWidget::environmentChanged); } -EnvironmentAspect *EnvironmentAspectWidget::aspect() const -{ - return m_aspect; -} - QWidget *EnvironmentAspectWidget::additionalWidget() const { return m_additionalWidget; diff --git a/src/plugins/projectexplorer/environmentaspectwidget.h b/src/plugins/projectexplorer/environmentaspectwidget.h index 44acee2f616..bb51a14bee8 100644 --- a/src/plugins/projectexplorer/environmentaspectwidget.h +++ b/src/plugins/projectexplorer/environmentaspectwidget.h @@ -52,9 +52,9 @@ class PROJECTEXPLORER_EXPORT EnvironmentAspectWidget : public QWidget public: explicit EnvironmentAspectWidget(EnvironmentAspect *aspect, QWidget *additionalWidget = nullptr); - virtual EnvironmentAspect *aspect() const; +protected: + EnvironmentAspect *aspect() const { return m_aspect; } EnvironmentWidget *envWidget() const { return m_environmentWidget; } - QWidget *additionalWidget() const; private: diff --git a/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp b/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp index 0aab43c44ab..309509ec149 100644 --- a/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp +++ b/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp @@ -52,8 +52,8 @@ const QString FetchEnvButtonText namespace RemoteLinux { RemoteLinuxEnvironmentAspectWidget::RemoteLinuxEnvironmentAspectWidget - (RemoteLinuxEnvironmentAspect *aspect, Target *target) : - EnvironmentAspectWidget(aspect, new QPushButton) + (RemoteLinuxEnvironmentAspect *aspect, Target *target) + : EnvironmentAspectWidget(aspect, new QPushButton) { IDevice::ConstPtr device = DeviceKitAspect::device(target->kit()); @@ -85,11 +85,6 @@ RemoteLinuxEnvironmentAspectWidget::RemoteLinuxEnvironmentAspectWidget envWidget()->setOpenTerminalFunc(openTerminalFunc); } -RemoteLinuxEnvironmentAspect *RemoteLinuxEnvironmentAspectWidget::aspect() const -{ - return dynamic_cast(EnvironmentAspectWidget::aspect()); -} - QPushButton *RemoteLinuxEnvironmentAspectWidget::fetchButton() const { return qobject_cast(additionalWidget()); @@ -114,7 +109,8 @@ void RemoteLinuxEnvironmentAspectWidget::fetchEnvironmentFinished() connect(button, &QPushButton::clicked, this, &RemoteLinuxEnvironmentAspectWidget::fetchEnvironment); button->setText(FetchEnvButtonText); - aspect()->setRemoteEnvironment(deviceEnvReader->remoteEnvironment()); + qobject_cast(aspect())->setRemoteEnvironment( + deviceEnvReader->remoteEnvironment()); } void RemoteLinuxEnvironmentAspectWidget::fetchEnvironmentError(const QString &error) diff --git a/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.h b/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.h index ae254fda62b..cc03d7e75c0 100644 --- a/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.h +++ b/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.h @@ -43,10 +43,9 @@ public: RemoteLinuxEnvironmentAspectWidget(RemoteLinuxEnvironmentAspect *aspect, ProjectExplorer::Target *target); - RemoteLinuxEnvironmentAspect *aspect() const override; +private: QPushButton *fetchButton() const; -private: void fetchEnvironment(); void fetchEnvironmentFinished(); void fetchEnvironmentError(const QString &error); diff --git a/src/plugins/remotelinux/uploadandinstalltarpackagestep.cpp b/src/plugins/remotelinux/uploadandinstalltarpackagestep.cpp index a1bcfe58a6e..c320fc68cd1 100644 --- a/src/plugins/remotelinux/uploadandinstalltarpackagestep.cpp +++ b/src/plugins/remotelinux/uploadandinstalltarpackagestep.cpp @@ -185,7 +185,7 @@ UploadAndInstallTarPackageStep::UploadAndInstallTarPackageStep(BuildStepList *bs for (BuildStep *step : deployConfiguration()->stepList()->steps()) { if (step == this) break; - if ((pStep = dynamic_cast(step))) + if ((pStep = qobject_cast(step))) break; } if (!pStep) From f921578a67e4176be2179e63ebe5f7b0e393c25d Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 27 May 2022 11:39:18 +0200 Subject: [PATCH 04/12] EnvironmentAspectWidget: Add addWidget() method Replace additionalWidget() getter with addWidget() setter. Remove additionalWidget from c'tor. Change-Id: I955e00228ed9b6b49535569be782793c3bafccb8 Reviewed-by: Reviewed-by: Christian Kandeler --- .../environmentaspectwidget.cpp | 21 ++++------ .../projectexplorer/environmentaspectwidget.h | 8 ++-- .../remotelinuxenvironmentaspectwidget.cpp | 42 ++++++++----------- .../remotelinuxenvironmentaspectwidget.h | 5 +-- 4 files changed, 33 insertions(+), 43 deletions(-) diff --git a/src/plugins/projectexplorer/environmentaspectwidget.cpp b/src/plugins/projectexplorer/environmentaspectwidget.cpp index bb84a49f6a6..be332b289ff 100644 --- a/src/plugins/projectexplorer/environmentaspectwidget.cpp +++ b/src/plugins/projectexplorer/environmentaspectwidget.cpp @@ -41,9 +41,8 @@ namespace ProjectExplorer { // EnvironmentAspectWidget: // -------------------------------------------------------------------- -EnvironmentAspectWidget::EnvironmentAspectWidget(EnvironmentAspect *aspect, QWidget *additionalWidget) : - m_aspect(aspect), - m_additionalWidget(additionalWidget) +EnvironmentAspectWidget::EnvironmentAspectWidget(EnvironmentAspect *aspect) + : m_aspect(aspect) { QTC_CHECK(m_aspect); @@ -52,10 +51,10 @@ EnvironmentAspectWidget::EnvironmentAspectWidget(EnvironmentAspect *aspect, QWid topLayout->setContentsMargins(0, 0, 0, 25); auto baseEnvironmentWidget = new QWidget; - auto baseLayout = new QHBoxLayout(baseEnvironmentWidget); - baseLayout->setContentsMargins(0, 0, 0, 0); + m_baseLayout = new QHBoxLayout(baseEnvironmentWidget); + m_baseLayout->setContentsMargins(0, 0, 0, 0); auto label = new QLabel(tr("Base environment for this run configuration:"), this); - baseLayout->addWidget(label); + m_baseLayout->addWidget(label); m_baseEnvironmentComboBox = new QComboBox; for (const QString &displayName : m_aspect->displayNames()) @@ -67,10 +66,8 @@ EnvironmentAspectWidget::EnvironmentAspectWidget(EnvironmentAspect *aspect, QWid connect(m_baseEnvironmentComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &EnvironmentAspectWidget::baseEnvironmentSelected); - baseLayout->addWidget(m_baseEnvironmentComboBox); - baseLayout->addStretch(10); - if (additionalWidget) - baseLayout->addWidget(additionalWidget); + m_baseLayout->addWidget(m_baseEnvironmentComboBox); + m_baseLayout->addStretch(10); const EnvironmentWidget::Type widgetType = aspect->isLocal() ? EnvironmentWidget::TypeLocal : EnvironmentWidget::TypeRemote; @@ -92,9 +89,9 @@ EnvironmentAspectWidget::EnvironmentAspectWidget(EnvironmentAspect *aspect, QWid this, &EnvironmentAspectWidget::environmentChanged); } -QWidget *EnvironmentAspectWidget::additionalWidget() const +void EnvironmentAspectWidget::addWidget(QWidget *widget) { - return m_additionalWidget; + m_baseLayout->addWidget(widget); } void EnvironmentAspectWidget::baseEnvironmentSelected(int idx) diff --git a/src/plugins/projectexplorer/environmentaspectwidget.h b/src/plugins/projectexplorer/environmentaspectwidget.h index bb51a14bee8..9c30c373c7a 100644 --- a/src/plugins/projectexplorer/environmentaspectwidget.h +++ b/src/plugins/projectexplorer/environmentaspectwidget.h @@ -37,6 +37,7 @@ QT_BEGIN_NAMESPACE class QComboBox; +class QHBoxLayout; QT_END_NAMESPACE namespace Utils { class DetailsWidget; } @@ -50,12 +51,12 @@ class PROJECTEXPLORER_EXPORT EnvironmentAspectWidget : public QWidget Q_OBJECT public: - explicit EnvironmentAspectWidget(EnvironmentAspect *aspect, QWidget *additionalWidget = nullptr); + explicit EnvironmentAspectWidget(EnvironmentAspect *aspect); protected: EnvironmentAspect *aspect() const { return m_aspect; } EnvironmentWidget *envWidget() const { return m_environmentWidget; } - QWidget *additionalWidget() const; + void addWidget(QWidget *widget); private: void baseEnvironmentSelected(int idx); @@ -66,8 +67,7 @@ private: EnvironmentAspect *m_aspect; bool m_ignoreChange = false; - - QWidget *m_additionalWidget = nullptr; + QHBoxLayout *m_baseLayout = nullptr; QComboBox *m_baseEnvironmentComboBox = nullptr; EnvironmentWidget *m_environmentWidget = nullptr; }; diff --git a/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp b/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp index 309509ec149..53b4aa8fee5 100644 --- a/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp +++ b/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp @@ -53,20 +53,21 @@ namespace RemoteLinux { RemoteLinuxEnvironmentAspectWidget::RemoteLinuxEnvironmentAspectWidget (RemoteLinuxEnvironmentAspect *aspect, Target *target) - : EnvironmentAspectWidget(aspect, new QPushButton) + : EnvironmentAspectWidget(aspect) + , m_fetchButton(new QPushButton(FetchEnvButtonText)) { + addWidget(m_fetchButton); + IDevice::ConstPtr device = DeviceKitAspect::device(target->kit()); - deviceEnvReader = new RemoteLinuxEnvironmentReader(device, this); + m_deviceEnvReader = new RemoteLinuxEnvironmentReader(device, this); connect(target, &ProjectExplorer::Target::kitChanged, - deviceEnvReader, &RemoteLinuxEnvironmentReader::handleCurrentDeviceConfigChanged); + m_deviceEnvReader, &RemoteLinuxEnvironmentReader::handleCurrentDeviceConfigChanged); - QPushButton *button = fetchButton(); - button->setText(FetchEnvButtonText); - connect(button, &QPushButton::clicked, this, &RemoteLinuxEnvironmentAspectWidget::fetchEnvironment); - connect(deviceEnvReader, &RemoteLinuxEnvironmentReader::finished, + connect(m_fetchButton, &QPushButton::clicked, this, &RemoteLinuxEnvironmentAspectWidget::fetchEnvironment); + connect(m_deviceEnvReader, &RemoteLinuxEnvironmentReader::finished, this, &RemoteLinuxEnvironmentAspectWidget::fetchEnvironmentFinished); - connect(deviceEnvReader, &RemoteLinuxEnvironmentReader::error, + connect(m_deviceEnvReader, &RemoteLinuxEnvironmentReader::error, this, &RemoteLinuxEnvironmentAspectWidget::fetchEnvironmentError); const EnvironmentWidget::OpenTerminalFunc openTerminalFunc @@ -85,32 +86,25 @@ RemoteLinuxEnvironmentAspectWidget::RemoteLinuxEnvironmentAspectWidget envWidget()->setOpenTerminalFunc(openTerminalFunc); } -QPushButton *RemoteLinuxEnvironmentAspectWidget::fetchButton() const -{ - return qobject_cast(additionalWidget()); -} - void RemoteLinuxEnvironmentAspectWidget::fetchEnvironment() { - QPushButton *button = fetchButton(); - disconnect(button, &QPushButton::clicked, + disconnect(m_fetchButton, &QPushButton::clicked, this, &RemoteLinuxEnvironmentAspectWidget::fetchEnvironment); - connect(button, &QPushButton::clicked, + connect(m_fetchButton, &QPushButton::clicked, this, &RemoteLinuxEnvironmentAspectWidget::stopFetchEnvironment); - button->setText(tr("Cancel Fetch Operation")); - deviceEnvReader->start(); + m_fetchButton->setText(tr("Cancel Fetch Operation")); + m_deviceEnvReader->start(); } void RemoteLinuxEnvironmentAspectWidget::fetchEnvironmentFinished() { - QPushButton *button = fetchButton(); - disconnect(button, &QPushButton::clicked, + disconnect(m_fetchButton, &QPushButton::clicked, this, &RemoteLinuxEnvironmentAspectWidget::stopFetchEnvironment); - connect(button, &QPushButton::clicked, + connect(m_fetchButton, &QPushButton::clicked, this, &RemoteLinuxEnvironmentAspectWidget::fetchEnvironment); - button->setText(FetchEnvButtonText); + m_fetchButton->setText(FetchEnvButtonText); qobject_cast(aspect())->setRemoteEnvironment( - deviceEnvReader->remoteEnvironment()); + m_deviceEnvReader->remoteEnvironment()); } void RemoteLinuxEnvironmentAspectWidget::fetchEnvironmentError(const QString &error) @@ -121,7 +115,7 @@ void RemoteLinuxEnvironmentAspectWidget::fetchEnvironmentError(const QString &er void RemoteLinuxEnvironmentAspectWidget::stopFetchEnvironment() { - deviceEnvReader->stop(); + m_deviceEnvReader->stop(); fetchEnvironmentFinished(); } diff --git a/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.h b/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.h index cc03d7e75c0..e31c85b9a31 100644 --- a/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.h +++ b/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.h @@ -44,14 +44,13 @@ public: ProjectExplorer::Target *target); private: - QPushButton *fetchButton() const; - void fetchEnvironment(); void fetchEnvironmentFinished(); void fetchEnvironmentError(const QString &error); void stopFetchEnvironment(); - Internal::RemoteLinuxEnvironmentReader *deviceEnvReader; + Internal::RemoteLinuxEnvironmentReader *m_deviceEnvReader = nullptr; + QPushButton *m_fetchButton = nullptr; }; } // namespace RemoteLinux From cda2e97ce53a8c98fe38a03b0c356c42315f0e84 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 27 May 2022 12:31:46 +0200 Subject: [PATCH 05/12] Rename UploadAndInstallTarPackageStep into TarPackageDeployStep Make class name shorter and consistent with others. Change-Id: I7102c981848b2a2854421d5b8b947dea81a1799a Reviewed-by: Christian Kandeler Reviewed-by: Reviewed-by: Qt CI Bot --- src/plugins/remotelinux/CMakeLists.txt | 2 +- src/plugins/remotelinux/remotelinux.qbs | 4 +- .../remotelinux/remotelinux_constants.h | 2 +- src/plugins/remotelinux/remotelinuxplugin.cpp | 4 +- ...ckagestep.cpp => tarpackagedeploystep.cpp} | 42 +++++++++---------- ...arpackagestep.h => tarpackagedeploystep.h} | 4 +- 6 files changed, 29 insertions(+), 29 deletions(-) rename src/plugins/remotelinux/{uploadandinstalltarpackagestep.cpp => tarpackagedeploystep.cpp} (79%) rename src/plugins/remotelinux/{uploadandinstalltarpackagestep.h => tarpackagedeploystep.h} (88%) diff --git a/src/plugins/remotelinux/CMakeLists.txt b/src/plugins/remotelinux/CMakeLists.txt index 1572a39d54d..c9d7b2df0f5 100644 --- a/src/plugins/remotelinux/CMakeLists.txt +++ b/src/plugins/remotelinux/CMakeLists.txt @@ -39,7 +39,7 @@ add_qtc_plugin(RemoteLinux sshkeycreationdialog.cpp sshkeycreationdialog.h sshkeycreationdialog.ui sshprocessinterface.h tarpackagecreationstep.cpp tarpackagecreationstep.h - uploadandinstalltarpackagestep.cpp uploadandinstalltarpackagestep.h + tarpackagedeploystep.cpp tarpackagedeploystep.h ) extend_qtc_plugin(RemoteLinux diff --git a/src/plugins/remotelinux/remotelinux.qbs b/src/plugins/remotelinux/remotelinux.qbs index 5bf01c2c49f..f7add4f572b 100644 --- a/src/plugins/remotelinux/remotelinux.qbs +++ b/src/plugins/remotelinux/remotelinux.qbs @@ -83,8 +83,8 @@ Project { "sshprocessinterface.h", "tarpackagecreationstep.cpp", "tarpackagecreationstep.h", - "uploadandinstalltarpackagestep.cpp", - "uploadandinstalltarpackagestep.h", + "tarpackagedeploystep.cpp", + "tarpackagedeploystep.h", "images/embeddedtarget.png", ] diff --git a/src/plugins/remotelinux/remotelinux_constants.h b/src/plugins/remotelinux/remotelinux_constants.h index c3fcdad4a51..843a3d96f36 100644 --- a/src/plugins/remotelinux/remotelinux_constants.h +++ b/src/plugins/remotelinux/remotelinux_constants.h @@ -34,7 +34,7 @@ const char CheckForFreeDiskSpaceId[] = "RemoteLinux.CheckForFreeDiskSpaceStep"; const char DirectUploadStepId[] = "RemoteLinux.DirectUploadStep"; const char MakeInstallStepId[] = "RemoteLinux.MakeInstall"; const char TarPackageCreationStepId[] = "MaemoTarPackageCreationStep"; -const char UploadAndInstallTarPackageStepId[] = "MaemoUploadAndInstallTarPackageStep"; +const char TarPackageDeployStepId[] = "MaemoUploadAndInstallTarPackageStep"; const char RsyncDeployStepId[] = "RemoteLinux.RsyncDeployStep"; const char CustomCommandDeployStepId[] = "RemoteLinux.GenericRemoteLinuxCustomCommandDeploymentStep"; const char KillAppStepId[] = "RemoteLinux.KillAppStep"; diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp index 86a55970d27..a4239ca2e72 100644 --- a/src/plugins/remotelinux/remotelinuxplugin.cpp +++ b/src/plugins/remotelinux/remotelinuxplugin.cpp @@ -41,7 +41,7 @@ #include "killappstep.h" #include "rsyncdeploystep.h" #include "tarpackagecreationstep.h" -#include "uploadandinstalltarpackagestep.h" +#include "tarpackagedeploystep.h" #ifdef WITH_TESTS #include "filesystemaccess_test.h" @@ -76,7 +76,7 @@ public: RemoteLinuxCustomRunConfigurationFactory customRunConfigurationFactory; RemoteLinuxDeployConfigurationFactory deployConfigurationFactory; GenericDeployStepFactory tarPackageCreationStepFactory; - GenericDeployStepFactory uploadAndInstallTarPackageStepFactory; + GenericDeployStepFactory tarPackageDeployStepFactory; GenericDeployStepFactory genericDirectUploadStepFactory; GenericDeployStepFactory rsyncDeployStepFactory; GenericDeployStepFactory diff --git a/src/plugins/remotelinux/uploadandinstalltarpackagestep.cpp b/src/plugins/remotelinux/tarpackagedeploystep.cpp similarity index 79% rename from src/plugins/remotelinux/uploadandinstalltarpackagestep.cpp rename to src/plugins/remotelinux/tarpackagedeploystep.cpp index c320fc68cd1..d6a58c33c32 100644 --- a/src/plugins/remotelinux/uploadandinstalltarpackagestep.cpp +++ b/src/plugins/remotelinux/tarpackagedeploystep.cpp @@ -23,7 +23,7 @@ ** ****************************************************************************/ -#include "uploadandinstalltarpackagestep.h" +#include "tarpackagedeploystep.h" #include "remotelinux_constants.h" #include "remotelinuxpackageinstaller.h" @@ -43,12 +43,12 @@ using namespace Utils; namespace RemoteLinux { namespace Internal { -class UploadAndInstallTarPackageService : public AbstractRemoteLinuxDeployService +class TarPackageDeployService : public AbstractRemoteLinuxDeployService { Q_OBJECT public: - UploadAndInstallTarPackageService(); + TarPackageDeployService(); void setPackageFilePath(const FilePath &filePath); private: @@ -71,30 +71,30 @@ private: RemoteLinuxTarPackageInstaller m_installer; }; -UploadAndInstallTarPackageService::UploadAndInstallTarPackageService() +TarPackageDeployService::TarPackageDeployService() { connect(&m_uploader, &FileTransfer::done, this, - &UploadAndInstallTarPackageService::handleUploadFinished); + &TarPackageDeployService::handleUploadFinished); connect(&m_uploader, &FileTransfer::progress, this, - &UploadAndInstallTarPackageService::progressMessage); + &TarPackageDeployService::progressMessage); } -void UploadAndInstallTarPackageService::setPackageFilePath(const FilePath &filePath) +void TarPackageDeployService::setPackageFilePath(const FilePath &filePath) { m_packageFilePath = filePath; } -QString UploadAndInstallTarPackageService::uploadDir() const +QString TarPackageDeployService::uploadDir() const { return QLatin1String("/tmp"); } -bool UploadAndInstallTarPackageService::isDeploymentNecessary() const +bool TarPackageDeployService::isDeploymentNecessary() const { return hasLocalFileChanged(DeployableFile(m_packageFilePath, {})); } -void UploadAndInstallTarPackageService::doDeploy() +void TarPackageDeployService::doDeploy() { QTC_ASSERT(m_state == Inactive, return); @@ -107,7 +107,7 @@ void UploadAndInstallTarPackageService::doDeploy() m_uploader.start(); } -void UploadAndInstallTarPackageService::stopDeployment() +void TarPackageDeployService::stopDeployment() { switch (m_state) { case Inactive: @@ -124,7 +124,7 @@ void UploadAndInstallTarPackageService::stopDeployment() } } -void UploadAndInstallTarPackageService::handleUploadFinished(const ProcessResultData &resultData) +void TarPackageDeployService::handleUploadFinished(const ProcessResultData &resultData) { QTC_ASSERT(m_state == Uploading, return); @@ -143,11 +143,11 @@ void UploadAndInstallTarPackageService::handleUploadFinished(const ProcessResult connect(&m_installer, &AbstractRemoteLinuxPackageInstaller::stderrData, this, &AbstractRemoteLinuxDeployService::stdErrData); connect(&m_installer, &AbstractRemoteLinuxPackageInstaller::finished, - this, &UploadAndInstallTarPackageService::handleInstallationFinished); + this, &TarPackageDeployService::handleInstallationFinished); m_installer.installPackage(deviceConfiguration(), remoteFilePath, true); } -void UploadAndInstallTarPackageService::handleInstallationFinished(const QString &errorMsg) +void TarPackageDeployService::handleInstallationFinished(const QString &errorMsg) { QTC_ASSERT(m_state == Installing, return); @@ -160,7 +160,7 @@ void UploadAndInstallTarPackageService::handleInstallationFinished(const QString setFinished(); } -void UploadAndInstallTarPackageService::setFinished() +void TarPackageDeployService::setFinished() { m_state = Inactive; m_uploader.stop(); @@ -172,10 +172,10 @@ void UploadAndInstallTarPackageService::setFinished() using namespace Internal; -UploadAndInstallTarPackageStep::UploadAndInstallTarPackageStep(BuildStepList *bsl, Id id) +TarPackageDeployStep::TarPackageDeployStep(BuildStepList *bsl, Id id) : AbstractRemoteLinuxDeployStep(bsl, id) { - auto service = createDeployService(); + auto service = createDeployService(); setWidgetExpandedByDefault(false); @@ -196,16 +196,16 @@ UploadAndInstallTarPackageStep::UploadAndInstallTarPackageStep(BuildStepList *bs }); } -Id UploadAndInstallTarPackageStep::stepId() +Id TarPackageDeployStep::stepId() { - return Constants::UploadAndInstallTarPackageStepId; + return Constants::TarPackageDeployStepId; } -QString UploadAndInstallTarPackageStep::displayName() +QString TarPackageDeployStep::displayName() { return tr("Deploy tarball via SFTP upload"); } } //namespace RemoteLinux -#include "uploadandinstalltarpackagestep.moc" +#include "tarpackagedeploystep.moc" diff --git a/src/plugins/remotelinux/uploadandinstalltarpackagestep.h b/src/plugins/remotelinux/tarpackagedeploystep.h similarity index 88% rename from src/plugins/remotelinux/uploadandinstalltarpackagestep.h rename to src/plugins/remotelinux/tarpackagedeploystep.h index 5d120dc7271..63eee8b2e5b 100644 --- a/src/plugins/remotelinux/uploadandinstalltarpackagestep.h +++ b/src/plugins/remotelinux/tarpackagedeploystep.h @@ -30,12 +30,12 @@ namespace RemoteLinux { class AbstractRemoteLinuxPackageInstaller; -class REMOTELINUX_EXPORT UploadAndInstallTarPackageStep : public AbstractRemoteLinuxDeployStep +class TarPackageDeployStep : public AbstractRemoteLinuxDeployStep { Q_OBJECT public: - UploadAndInstallTarPackageStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id); + TarPackageDeployStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id); static Utils::Id stepId(); static QString displayName(); From 9ce6ad6a06d11f702317ab3cf7983a09264dcfe3 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 27 May 2022 13:39:30 +0200 Subject: [PATCH 06/12] RemoteLinux: Hide RemoteLinuxPackageInstaller Remove AbstractRemoteLinuxPackageInstaller, as we have only one subclass. Don't export RemoteLinuxPackageInstaller, as it's used only by TarPackageDeployStep. Rename RemoteLinuxPackageInstaller into TarPackageInstaller and hide it inside tarpackagedeploystep.cpp. Change-Id: I1dacdeda58378911cc322b9991f4f584c074db1b Reviewed-by: Christian Kandeler Reviewed-by: Qt CI Bot Reviewed-by: --- src/plugins/remotelinux/CMakeLists.txt | 1 - src/plugins/remotelinux/remotelinux.qbs | 2 - .../remotelinuxpackageinstaller.cpp | 107 ------------------ .../remotelinux/remotelinuxpackageinstaller.h | 79 ------------- .../remotelinux/tarpackagedeploystep.cpp | 71 +++++++++++- .../remotelinux/tarpackagedeploystep.h | 1 - 6 files changed, 66 insertions(+), 195 deletions(-) delete mode 100644 src/plugins/remotelinux/remotelinuxpackageinstaller.cpp delete mode 100644 src/plugins/remotelinux/remotelinuxpackageinstaller.h diff --git a/src/plugins/remotelinux/CMakeLists.txt b/src/plugins/remotelinux/CMakeLists.txt index c9d7b2df0f5..7111f55b767 100644 --- a/src/plugins/remotelinux/CMakeLists.txt +++ b/src/plugins/remotelinux/CMakeLists.txt @@ -29,7 +29,6 @@ add_qtc_plugin(RemoteLinux remotelinuxenvironmentaspect.cpp remotelinuxenvironmentaspect.h remotelinuxenvironmentaspectwidget.cpp remotelinuxenvironmentaspectwidget.h remotelinuxenvironmentreader.cpp remotelinuxenvironmentreader.h - remotelinuxpackageinstaller.cpp remotelinuxpackageinstaller.h remotelinuxplugin.cpp remotelinuxplugin.h remotelinuxqmltoolingsupport.cpp remotelinuxqmltoolingsupport.h remotelinuxrunconfiguration.cpp remotelinuxrunconfiguration.h diff --git a/src/plugins/remotelinux/remotelinux.qbs b/src/plugins/remotelinux/remotelinux.qbs index f7add4f572b..15170415cf4 100644 --- a/src/plugins/remotelinux/remotelinux.qbs +++ b/src/plugins/remotelinux/remotelinux.qbs @@ -63,8 +63,6 @@ Project { "remotelinuxenvironmentaspectwidget.h", "remotelinuxenvironmentreader.cpp", "remotelinuxenvironmentreader.h", - "remotelinuxpackageinstaller.cpp", - "remotelinuxpackageinstaller.h", "remotelinuxplugin.cpp", "remotelinuxplugin.h", "remotelinuxqmltoolingsupport.cpp", diff --git a/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp b/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp deleted file mode 100644 index 828c5a5a361..00000000000 --- a/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp +++ /dev/null @@ -1,107 +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 "remotelinuxpackageinstaller.h" - -#include - -#include -#include -#include - -using namespace ProjectExplorer; -using namespace Utils; - -namespace RemoteLinux { -namespace Internal { - -class AbstractRemoteLinuxPackageInstallerPrivate -{ -public: - IDevice::ConstPtr m_device; - QtcProcess m_installer; - QtcProcess m_killer; -}; - -} // namespace Internal - -AbstractRemoteLinuxPackageInstaller::AbstractRemoteLinuxPackageInstaller(QObject *parent) - : QObject(parent), d(new Internal::AbstractRemoteLinuxPackageInstallerPrivate) -{ - connect(&d->m_installer, &QtcProcess::readyReadStandardOutput, this, [this] { - emit stdoutData(QString::fromUtf8(d->m_installer.readAllStandardOutput())); - }); - connect(&d->m_installer, &QtcProcess::readyReadStandardError, this, [this] { - emit stderrData(QString::fromUtf8(d->m_installer.readAllStandardError())); - }); - connect(&d->m_installer, &QtcProcess::finished, this, [this] { - const QString errorMessage = d->m_installer.result() == ProcessResult::FinishedWithSuccess - ? QString() : tr("Installing package failed.") + d->m_installer.errorString(); - emit finished(errorMessage); - }); -} - -AbstractRemoteLinuxPackageInstaller::~AbstractRemoteLinuxPackageInstaller() = default; - -void AbstractRemoteLinuxPackageInstaller::installPackage(const IDevice::ConstPtr &deviceConfig, - const QString &packageFilePath, bool removePackageFile) -{ - QTC_ASSERT(d->m_installer.state() == QProcess::NotRunning, return); - - d->m_device = deviceConfig; - - QString cmdLine = installCommandLine(packageFilePath); - if (removePackageFile) - cmdLine += QLatin1String(" && (rm ") + packageFilePath + QLatin1String(" || :)"); - d->m_installer.setCommand({d->m_device->filePath("/bin/sh"), {"-c", cmdLine}}); - d->m_installer.start(); -} - -void AbstractRemoteLinuxPackageInstaller::cancelInstallation() -{ - QTC_ASSERT(d->m_installer.state() != QProcess::NotRunning, return); - - d->m_killer.setCommand({d->m_device->filePath("/bin/sh"), - {"-c", cancelInstallationCommandLine()}}); - d->m_killer.start(); - d->m_installer.close(); -} - -RemoteLinuxTarPackageInstaller::RemoteLinuxTarPackageInstaller(QObject *parent) - : AbstractRemoteLinuxPackageInstaller(parent) -{ -} - -QString RemoteLinuxTarPackageInstaller::installCommandLine(const QString &packageFilePath) const -{ - return QLatin1String("cd / && tar xvf ") + packageFilePath; -} - -QString RemoteLinuxTarPackageInstaller::cancelInstallationCommandLine() const -{ - return QLatin1String("pkill tar"); -} - -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/remotelinuxpackageinstaller.h b/src/plugins/remotelinux/remotelinuxpackageinstaller.h deleted file mode 100644 index 74a5e06b99d..00000000000 --- a/src/plugins/remotelinux/remotelinuxpackageinstaller.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 "remotelinux_export.h" - -#include - -#include - -#include - -namespace RemoteLinux { - -namespace Internal { class AbstractRemoteLinuxPackageInstallerPrivate; } - -class REMOTELINUX_EXPORT AbstractRemoteLinuxPackageInstaller : public QObject -{ - Q_OBJECT - Q_DISABLE_COPY(AbstractRemoteLinuxPackageInstaller) -public: - ~AbstractRemoteLinuxPackageInstaller() override; - - void installPackage(const ProjectExplorer::IDeviceConstPtr &deviceConfig, - const QString &packageFilePath, bool removePackageFile); - void cancelInstallation(); - -signals: - void stdoutData(const QString &output); - void stderrData(const QString &output); - void finished(const QString &errorMsg = QString()); - -protected: - explicit AbstractRemoteLinuxPackageInstaller(QObject *parent = nullptr); - -private: - virtual QString installCommandLine(const QString &packageFilePath) const = 0; - virtual QString cancelInstallationCommandLine() const = 0; - - std::unique_ptr d; -}; - - -class REMOTELINUX_EXPORT RemoteLinuxTarPackageInstaller : public AbstractRemoteLinuxPackageInstaller -{ - Q_OBJECT -public: - RemoteLinuxTarPackageInstaller(QObject *parent = nullptr); - -private: - QString installCommandLine(const QString &packageFilePath) const override; - QString cancelInstallationCommandLine() const override; -}; - - -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/tarpackagedeploystep.cpp b/src/plugins/remotelinux/tarpackagedeploystep.cpp index d6a58c33c32..7247d165c4f 100644 --- a/src/plugins/remotelinux/tarpackagedeploystep.cpp +++ b/src/plugins/remotelinux/tarpackagedeploystep.cpp @@ -26,7 +26,6 @@ #include "tarpackagedeploystep.h" #include "remotelinux_constants.h" -#include "remotelinuxpackageinstaller.h" #include "tarpackagecreationstep.h" #include @@ -34,6 +33,7 @@ #include #include +#include #include @@ -43,6 +43,67 @@ using namespace Utils; namespace RemoteLinux { namespace Internal { +class TarPackageInstaller : public QObject +{ + Q_OBJECT + +public: + TarPackageInstaller(QObject *parent = nullptr); + + void installPackage(const ProjectExplorer::IDeviceConstPtr &deviceConfig, + const QString &packageFilePath, bool removePackageFile); + void cancelInstallation(); + +signals: + void stdoutData(const QString &output); + void stderrData(const QString &output); + void finished(const QString &errorMsg = QString()); + +private: + IDevice::ConstPtr m_device; + QtcProcess m_installer; + QtcProcess m_killer; +}; + +TarPackageInstaller::TarPackageInstaller(QObject *parent) + : QObject(parent) +{ + connect(&m_installer, &QtcProcess::readyReadStandardOutput, this, [this] { + emit stdoutData(QString::fromUtf8(m_installer.readAllStandardOutput())); + }); + connect(&m_installer, &QtcProcess::readyReadStandardError, this, [this] { + emit stderrData(QString::fromUtf8(m_installer.readAllStandardError())); + }); + connect(&m_installer, &QtcProcess::finished, this, [this] { + const QString errorMessage = m_installer.result() == ProcessResult::FinishedWithSuccess + ? QString() : tr("Installing package failed.") + m_installer.errorString(); + emit finished(errorMessage); + }); +} + +void TarPackageInstaller::installPackage(const IDevice::ConstPtr &deviceConfig, + const QString &packageFilePath, bool removePackageFile) +{ + QTC_ASSERT(m_installer.state() == QProcess::NotRunning, return); + + m_device = deviceConfig; + + QString cmdLine = QLatin1String("cd / && tar xvf ") + packageFilePath; + if (removePackageFile) + cmdLine += QLatin1String(" && (rm ") + packageFilePath + QLatin1String(" || :)"); + m_installer.setCommand({m_device->filePath("/bin/sh"), {"-c", cmdLine}}); + m_installer.start(); +} + +void TarPackageInstaller::cancelInstallation() +{ + QTC_ASSERT(m_installer.state() != QProcess::NotRunning, return); + + m_killer.setCommand({m_device->filePath("/bin/sh"), {"-c", "pkill tar"}}); + m_killer.start(); + m_installer.close(); +} + class TarPackageDeployService : public AbstractRemoteLinuxDeployService { Q_OBJECT @@ -68,7 +129,7 @@ private: State m_state = Inactive; FileTransfer m_uploader; FilePath m_packageFilePath; - RemoteLinuxTarPackageInstaller m_installer; + TarPackageInstaller m_installer; }; TarPackageDeployService::TarPackageDeployService() @@ -138,11 +199,11 @@ void TarPackageDeployService::handleUploadFinished(const ProcessResultData &resu const QString remoteFilePath = uploadDir() + '/' + m_packageFilePath.fileName(); m_state = Installing; emit progressMessage(tr("Installing package to device...")); - connect(&m_installer, &AbstractRemoteLinuxPackageInstaller::stdoutData, + connect(&m_installer, &TarPackageInstaller::stdoutData, this, &AbstractRemoteLinuxDeployService::stdOutData); - connect(&m_installer, &AbstractRemoteLinuxPackageInstaller::stderrData, + connect(&m_installer, &TarPackageInstaller::stderrData, this, &AbstractRemoteLinuxDeployService::stdErrData); - connect(&m_installer, &AbstractRemoteLinuxPackageInstaller::finished, + connect(&m_installer, &TarPackageInstaller::finished, this, &TarPackageDeployService::handleInstallationFinished); m_installer.installPackage(deviceConfiguration(), remoteFilePath, true); } diff --git a/src/plugins/remotelinux/tarpackagedeploystep.h b/src/plugins/remotelinux/tarpackagedeploystep.h index 63eee8b2e5b..e1113bebcbc 100644 --- a/src/plugins/remotelinux/tarpackagedeploystep.h +++ b/src/plugins/remotelinux/tarpackagedeploystep.h @@ -28,7 +28,6 @@ #include "abstractremotelinuxdeploystep.h" namespace RemoteLinux { -class AbstractRemoteLinuxPackageInstaller; class TarPackageDeployStep : public AbstractRemoteLinuxDeployStep { From 0386c101e966f21aed4ee50e7f50af7e15f1ac0a Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 27 May 2022 13:49:23 +0200 Subject: [PATCH 07/12] Rename remotelinuxx11forwardingaspect.h into x11forwardingaspect.h In this way we match the filename with a class name. Change-Id: Ie0ae686b15aa27e2e00557ee32c6f84b956cf855 Reviewed-by: Reviewed-by: Christian Kandeler --- src/plugins/remotelinux/CMakeLists.txt | 2 +- src/plugins/remotelinux/remotelinux.qbs | 4 ++-- src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp | 2 +- src/plugins/remotelinux/remotelinuxrunconfiguration.cpp | 2 +- ...telinuxx11forwardingaspect.cpp => x11forwardingaspect.cpp} | 2 +- ...remotelinuxx11forwardingaspect.h => x11forwardingaspect.h} | 0 6 files changed, 6 insertions(+), 6 deletions(-) rename src/plugins/remotelinux/{remotelinuxx11forwardingaspect.cpp => x11forwardingaspect.cpp} (97%) rename src/plugins/remotelinux/{remotelinuxx11forwardingaspect.h => x11forwardingaspect.h} (100%) diff --git a/src/plugins/remotelinux/CMakeLists.txt b/src/plugins/remotelinux/CMakeLists.txt index 7111f55b767..a29886139c0 100644 --- a/src/plugins/remotelinux/CMakeLists.txt +++ b/src/plugins/remotelinux/CMakeLists.txt @@ -33,12 +33,12 @@ add_qtc_plugin(RemoteLinux remotelinuxqmltoolingsupport.cpp remotelinuxqmltoolingsupport.h remotelinuxrunconfiguration.cpp remotelinuxrunconfiguration.h remotelinuxsignaloperation.cpp remotelinuxsignaloperation.h - remotelinuxx11forwardingaspect.cpp remotelinuxx11forwardingaspect.h rsyncdeploystep.cpp rsyncdeploystep.h sshkeycreationdialog.cpp sshkeycreationdialog.h sshkeycreationdialog.ui sshprocessinterface.h tarpackagecreationstep.cpp tarpackagecreationstep.h tarpackagedeploystep.cpp tarpackagedeploystep.h + x11forwardingaspect.cpp x11forwardingaspect.h ) extend_qtc_plugin(RemoteLinux diff --git a/src/plugins/remotelinux/remotelinux.qbs b/src/plugins/remotelinux/remotelinux.qbs index 15170415cf4..cdaf40f11a5 100644 --- a/src/plugins/remotelinux/remotelinux.qbs +++ b/src/plugins/remotelinux/remotelinux.qbs @@ -71,8 +71,6 @@ Project { "remotelinuxrunconfiguration.h", "remotelinuxsignaloperation.cpp", "remotelinuxsignaloperation.h", - "remotelinuxx11forwardingaspect.cpp", - "remotelinuxx11forwardingaspect.h", "rsyncdeploystep.cpp", "rsyncdeploystep.h", "sshkeycreationdialog.cpp", @@ -83,6 +81,8 @@ Project { "tarpackagecreationstep.h", "tarpackagedeploystep.cpp", "tarpackagedeploystep.h", + "x11forwardingaspect.cpp", + "x11forwardingaspect.h", "images/embeddedtarget.png", ] diff --git a/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp b/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp index 6009c502696..fe704f0705b 100644 --- a/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp +++ b/src/plugins/remotelinux/remotelinuxcustomrunconfiguration.cpp @@ -27,7 +27,7 @@ #include "remotelinux_constants.h" #include "remotelinuxenvironmentaspect.h" -#include "remotelinuxx11forwardingaspect.h" +#include "x11forwardingaspect.h" #include #include diff --git a/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp b/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp index 44d1c677281..cc026da4db1 100644 --- a/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp +++ b/src/plugins/remotelinux/remotelinuxrunconfiguration.cpp @@ -26,8 +26,8 @@ #include "remotelinuxrunconfiguration.h" #include "remotelinux_constants.h" -#include "remotelinuxx11forwardingaspect.h" #include "remotelinuxenvironmentaspect.h" +#include "x11forwardingaspect.h" #include #include diff --git a/src/plugins/remotelinux/remotelinuxx11forwardingaspect.cpp b/src/plugins/remotelinux/x11forwardingaspect.cpp similarity index 97% rename from src/plugins/remotelinux/remotelinuxx11forwardingaspect.cpp rename to src/plugins/remotelinux/x11forwardingaspect.cpp index 3fbeba70cc1..952170a8224 100644 --- a/src/plugins/remotelinux/remotelinuxx11forwardingaspect.cpp +++ b/src/plugins/remotelinux/x11forwardingaspect.cpp @@ -23,7 +23,7 @@ ** ****************************************************************************/ -#include "remotelinuxx11forwardingaspect.h" +#include "x11forwardingaspect.h" #include #include diff --git a/src/plugins/remotelinux/remotelinuxx11forwardingaspect.h b/src/plugins/remotelinux/x11forwardingaspect.h similarity index 100% rename from src/plugins/remotelinux/remotelinuxx11forwardingaspect.h rename to src/plugins/remotelinux/x11forwardingaspect.h From 29e0f4dd979137b1d6e86376e10a7c8b9350c1a5 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 27 May 2022 14:24:23 +0200 Subject: [PATCH 08/12] Rename RemoteLinuxCustomCommandDeploymentStep ... into CustomCommandDeployStep Change-Id: I67e4d74f6df76ad301cb45926ecc550d9275d779 Reviewed-by: Christian Kandeler --- src/plugins/remotelinux/CMakeLists.txt | 2 +- ...ntstep.cpp => customcommanddeploystep.cpp} | 34 +++++++------------ ...oymentstep.h => customcommanddeploystep.h} | 6 ++-- src/plugins/remotelinux/remotelinux.qbs | 4 +-- src/plugins/remotelinux/remotelinuxplugin.cpp | 16 ++++----- 5 files changed, 25 insertions(+), 37 deletions(-) rename src/plugins/remotelinux/{remotelinuxcustomcommanddeploymentstep.cpp => customcommanddeploystep.cpp} (77%) rename src/plugins/remotelinux/{remotelinuxcustomcommanddeploymentstep.h => customcommanddeploystep.h} (84%) diff --git a/src/plugins/remotelinux/CMakeLists.txt b/src/plugins/remotelinux/CMakeLists.txt index a29886139c0..563d2c5ad9a 100644 --- a/src/plugins/remotelinux/CMakeLists.txt +++ b/src/plugins/remotelinux/CMakeLists.txt @@ -5,6 +5,7 @@ add_qtc_plugin(RemoteLinux abstractpackagingstep.cpp abstractpackagingstep.h abstractremotelinuxdeployservice.cpp abstractremotelinuxdeployservice.h abstractremotelinuxdeploystep.cpp abstractremotelinuxdeploystep.h + customcommanddeploystep.cpp customcommanddeploystep.h deploymenttimeinfo.cpp deploymenttimeinfo.h genericdirectuploadservice.cpp genericdirectuploadservice.h genericdirectuploadstep.cpp genericdirectuploadstep.h @@ -22,7 +23,6 @@ add_qtc_plugin(RemoteLinux remotelinux_constants.h remotelinux_export.h remotelinuxcheckforfreediskspacestep.cpp remotelinuxcheckforfreediskspacestep.h - remotelinuxcustomcommanddeploymentstep.cpp remotelinuxcustomcommanddeploymentstep.h remotelinuxcustomrunconfiguration.cpp remotelinuxcustomrunconfiguration.h remotelinuxdebugsupport.cpp remotelinuxdebugsupport.h remotelinuxdeployconfiguration.cpp remotelinuxdeployconfiguration.h diff --git a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp b/src/plugins/remotelinux/customcommanddeploystep.cpp similarity index 77% rename from src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp rename to src/plugins/remotelinux/customcommanddeploystep.cpp index b9054f3d724..6b5b91ef1cb 100644 --- a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.cpp +++ b/src/plugins/remotelinux/customcommanddeploystep.cpp @@ -23,7 +23,7 @@ ** ****************************************************************************/ -#include "remotelinuxcustomcommanddeploymentstep.h" +#include "customcommanddeploystep.h" #include "remotelinux_constants.h" @@ -38,14 +38,12 @@ using namespace Utils; namespace RemoteLinux { namespace Internal { -// RemoteLinuxCustomCommandDeployService - -class RemoteLinuxCustomCommandDeployService : public AbstractRemoteLinuxDeployService +class CustomCommandDeployService : public AbstractRemoteLinuxDeployService { - Q_DECLARE_TR_FUNCTIONS(RemoteLinux::Internal::RemoteLinuxCustomCommandDeployService) + Q_DECLARE_TR_FUNCTIONS(RemoteLinux::Internal::CustomCommandDeployService) public: - RemoteLinuxCustomCommandDeployService(); + CustomCommandDeployService(); void setCommandLine(const QString &commandLine); @@ -60,7 +58,7 @@ protected: QtcProcess m_process; }; -RemoteLinuxCustomCommandDeployService::RemoteLinuxCustomCommandDeployService() +CustomCommandDeployService::CustomCommandDeployService() { connect(&m_process, &QtcProcess::readyReadStandardOutput, this, [this] { emit stdOutData(QString::fromUtf8(m_process.readAllStandardOutput())); @@ -82,12 +80,12 @@ RemoteLinuxCustomCommandDeployService::RemoteLinuxCustomCommandDeployService() }); } -void RemoteLinuxCustomCommandDeployService::setCommandLine(const QString &commandLine) +void CustomCommandDeployService::setCommandLine(const QString &commandLine) { m_commandLine = commandLine; } -CheckResult RemoteLinuxCustomCommandDeployService::isDeploymentPossible() const +CheckResult CustomCommandDeployService::isDeploymentPossible() const { if (m_commandLine.isEmpty()) return CheckResult::failure(tr("No command line given.")); @@ -95,7 +93,7 @@ CheckResult RemoteLinuxCustomCommandDeployService::isDeploymentPossible() const return AbstractRemoteLinuxDeployService::isDeploymentPossible(); } -void RemoteLinuxCustomCommandDeployService::doDeploy() +void CustomCommandDeployService::doDeploy() { emit progressMessage(tr("Starting remote command \"%1\"...").arg(m_commandLine)); m_process.setCommand({deviceConfiguration()->filePath("/bin/sh"), @@ -103,7 +101,7 @@ void RemoteLinuxCustomCommandDeployService::doDeploy() m_process.start(); } -void RemoteLinuxCustomCommandDeployService::stopDeployment() +void CustomCommandDeployService::stopDeployment() { m_process.close(); handleDeploymentDone(); @@ -111,14 +109,10 @@ void RemoteLinuxCustomCommandDeployService::stopDeployment() } // Internal - -// RemoteLinuxCustomCommandDeploymentStep - -RemoteLinuxCustomCommandDeploymentStep::RemoteLinuxCustomCommandDeploymentStep - (BuildStepList *bsl, Utils::Id id) +CustomCommandDeployStep::CustomCommandDeployStep(BuildStepList *bsl, Utils::Id id) : AbstractRemoteLinuxDeployStep(bsl, id) { - auto service = createDeployService(); + auto service = createDeployService(); auto commandLine = addAspect(); commandLine->setSettingsKey("RemoteLinuxCustomCommandDeploymentStep.CommandLine"); @@ -134,14 +128,12 @@ RemoteLinuxCustomCommandDeploymentStep::RemoteLinuxCustomCommandDeploymentStep addMacroExpander(); } -RemoteLinuxCustomCommandDeploymentStep::~RemoteLinuxCustomCommandDeploymentStep() = default; - -Utils::Id RemoteLinuxCustomCommandDeploymentStep::stepId() +Utils::Id CustomCommandDeployStep::stepId() { return Constants::CustomCommandDeployStepId; } -QString RemoteLinuxCustomCommandDeploymentStep::displayName() +QString CustomCommandDeployStep::displayName() { return tr("Run custom remote command"); } diff --git a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h b/src/plugins/remotelinux/customcommanddeploystep.h similarity index 84% rename from src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h rename to src/plugins/remotelinux/customcommanddeploystep.h index 7200c201a0f..797fc90606d 100644 --- a/src/plugins/remotelinux/remotelinuxcustomcommanddeploymentstep.h +++ b/src/plugins/remotelinux/customcommanddeploystep.h @@ -29,14 +29,12 @@ namespace RemoteLinux { -class REMOTELINUX_EXPORT RemoteLinuxCustomCommandDeploymentStep - : public AbstractRemoteLinuxDeployStep +class REMOTELINUX_EXPORT CustomCommandDeployStep : public AbstractRemoteLinuxDeployStep { Q_OBJECT public: - RemoteLinuxCustomCommandDeploymentStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id); - ~RemoteLinuxCustomCommandDeploymentStep() override; + CustomCommandDeployStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id); static Utils::Id stepId(); static QString displayName(); diff --git a/src/plugins/remotelinux/remotelinux.qbs b/src/plugins/remotelinux/remotelinux.qbs index cdaf40f11a5..3ddf4537343 100644 --- a/src/plugins/remotelinux/remotelinux.qbs +++ b/src/plugins/remotelinux/remotelinux.qbs @@ -21,6 +21,8 @@ Project { "abstractremotelinuxdeploystep.h", "deploymenttimeinfo.cpp", "deploymenttimeinfo.h", + "customcommanddeploystep.cpp", + "customcommanddeploystep.h", "genericdirectuploadservice.cpp", "genericdirectuploadservice.h", "genericdirectuploadstep.cpp", @@ -49,8 +51,6 @@ Project { "remotelinux_export.h", "remotelinuxcheckforfreediskspacestep.cpp", "remotelinuxcheckforfreediskspacestep.h", - "remotelinuxcustomcommanddeploymentstep.cpp", - "remotelinuxcustomcommanddeploymentstep.h", "remotelinuxcustomrunconfiguration.cpp", "remotelinuxcustomrunconfiguration.h", "remotelinuxdebugsupport.cpp", diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp index a4239ca2e72..1c1c6e01ff4 100644 --- a/src/plugins/remotelinux/remotelinuxplugin.cpp +++ b/src/plugins/remotelinux/remotelinuxplugin.cpp @@ -25,20 +25,19 @@ #include "remotelinuxplugin.h" +#include "customcommanddeploystep.h" +#include "genericdirectuploadstep.h" +#include "killappstep.h" #include "linuxdevice.h" +#include "makeinstallstep.h" #include "remotelinux_constants.h" +#include "remotelinuxcheckforfreediskspacestep.h" +#include "remotelinuxdeployconfiguration.h" #include "remotelinuxqmltoolingsupport.h" #include "remotelinuxcustomrunconfiguration.h" #include "remotelinuxdebugsupport.h" #include "remotelinuxdeployconfiguration.h" #include "remotelinuxrunconfiguration.h" - -#include "genericdirectuploadstep.h" -#include "makeinstallstep.h" -#include "remotelinuxcheckforfreediskspacestep.h" -#include "remotelinuxdeployconfiguration.h" -#include "remotelinuxcustomcommanddeploymentstep.h" -#include "killappstep.h" #include "rsyncdeploystep.h" #include "tarpackagecreationstep.h" #include "tarpackagedeploystep.h" @@ -79,8 +78,7 @@ public: GenericDeployStepFactory tarPackageDeployStepFactory; GenericDeployStepFactory genericDirectUploadStepFactory; GenericDeployStepFactory rsyncDeployStepFactory; - GenericDeployStepFactory - customCommandDeploymentStepFactory; + GenericDeployStepFactory customCommandDeployStepFactory; GenericDeployStepFactory checkForFreeDiskSpaceStepFactory; GenericDeployStepFactory killAppStepFactory; From 4b5fd6740f038ceeded2238a4a99b9a5e855ce58 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 27 May 2022 14:57:17 +0200 Subject: [PATCH 09/12] Rename RemoteLinuxCheckForFreeDiskSpaceStep ... into CheckForFreeDiskSpaceStep Change-Id: I217c9f6b618f8e88aba64af07736c2966a76c782 Reviewed-by: Christian Kandeler --- src/plugins/boot2qt/qdbplugin.cpp | 4 +-- src/plugins/qnx/qnxplugin.cpp | 4 +-- src/plugins/remotelinux/CMakeLists.txt | 2 +- ...step.cpp => checkforfreediskspacestep.cpp} | 30 ++++++++----------- ...pacestep.h => checkforfreediskspacestep.h} | 5 ++-- src/plugins/remotelinux/remotelinux.qbs | 4 +-- .../remotelinuxdeployconfiguration.cpp | 4 +-- src/plugins/remotelinux/remotelinuxplugin.cpp | 5 ++-- 8 files changed, 25 insertions(+), 33 deletions(-) rename src/plugins/remotelinux/{remotelinuxcheckforfreediskspacestep.cpp => checkforfreediskspacestep.cpp} (81%) rename src/plugins/remotelinux/{remotelinuxcheckforfreediskspacestep.h => checkforfreediskspacestep.h} (84%) diff --git a/src/plugins/boot2qt/qdbplugin.cpp b/src/plugins/boot2qt/qdbplugin.cpp index 6bbfe4ba1e2..75f1b1c5287 100644 --- a/src/plugins/boot2qt/qdbplugin.cpp +++ b/src/plugins/boot2qt/qdbplugin.cpp @@ -45,9 +45,9 @@ #include +#include #include #include -#include #include #include @@ -176,7 +176,7 @@ public: QdbStopApplicationStepFactory m_stopApplicationStepFactory; QdbMakeDefaultAppStepFactory m_makeDefaultAppStepFactory; - QdbDeployStepFactory + QdbDeployStepFactory m_checkForFreeDiskSpaceStepFactory{RemoteLinux::Constants::CheckForFreeDiskSpaceId}; QdbDeployStepFactory m_directUploadStepFactory{RemoteLinux::Constants::DirectUploadStepId}; diff --git a/src/plugins/qnx/qnxplugin.cpp b/src/plugins/qnx/qnxplugin.cpp index 2adaa33d78b..b939efeae77 100644 --- a/src/plugins/qnx/qnxplugin.cpp +++ b/src/plugins/qnx/qnxplugin.cpp @@ -54,9 +54,9 @@ #include #include +#include #include #include -#include #include #include @@ -123,7 +123,7 @@ public: QnxDeviceFactory deviceFactory; QnxDeployConfigurationFactory deployConfigFactory; GenericQnxDeployStepFactory directUploadDeployFactory; - GenericQnxDeployStepFactory checkForFreeDiskSpaceDeployFactory; + GenericQnxDeployStepFactory checkForFreeDiskSpaceDeployFactory; GenericQnxDeployStepFactory makeInstallDeployFactory; GenericQnxDeployStepFactory checkBuildDeployFactory; QnxRunConfigurationFactory runConfigFactory; diff --git a/src/plugins/remotelinux/CMakeLists.txt b/src/plugins/remotelinux/CMakeLists.txt index 563d2c5ad9a..8c90671faa4 100644 --- a/src/plugins/remotelinux/CMakeLists.txt +++ b/src/plugins/remotelinux/CMakeLists.txt @@ -5,6 +5,7 @@ add_qtc_plugin(RemoteLinux abstractpackagingstep.cpp abstractpackagingstep.h abstractremotelinuxdeployservice.cpp abstractremotelinuxdeployservice.h abstractremotelinuxdeploystep.cpp abstractremotelinuxdeploystep.h + checkforfreediskspacestep.cpp checkforfreediskspacestep.h customcommanddeploystep.cpp customcommanddeploystep.h deploymenttimeinfo.cpp deploymenttimeinfo.h genericdirectuploadservice.cpp genericdirectuploadservice.h @@ -22,7 +23,6 @@ add_qtc_plugin(RemoteLinux remotelinux.qrc remotelinux_constants.h remotelinux_export.h - remotelinuxcheckforfreediskspacestep.cpp remotelinuxcheckforfreediskspacestep.h remotelinuxcustomrunconfiguration.cpp remotelinuxcustomrunconfiguration.h remotelinuxdebugsupport.cpp remotelinuxdebugsupport.h remotelinuxdeployconfiguration.cpp remotelinuxdeployconfiguration.h diff --git a/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.cpp b/src/plugins/remotelinux/checkforfreediskspacestep.cpp similarity index 81% rename from src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.cpp rename to src/plugins/remotelinux/checkforfreediskspacestep.cpp index a332c8183d8..0af58dd4a3c 100644 --- a/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.cpp +++ b/src/plugins/remotelinux/checkforfreediskspacestep.cpp @@ -23,7 +23,7 @@ ** ****************************************************************************/ -#include "remotelinuxcheckforfreediskspacestep.h" +#include "checkforfreediskspacestep.h" #include "abstractremotelinuxdeployservice.h" @@ -41,14 +41,12 @@ using namespace Utils; namespace RemoteLinux { -// RemoteLinuxCheckForFreeDiskSpaceService - -class RemoteLinuxCheckForFreeDiskSpaceService : public AbstractRemoteLinuxDeployService +class CheckForFreeDiskSpaceService : public AbstractRemoteLinuxDeployService { - Q_DECLARE_TR_FUNCTIONS(RemoteLinux::RemoteLinuxCheckForFreeDiskSpaceService) + Q_DECLARE_TR_FUNCTIONS(RemoteLinux::CheckForFreeDiskSpaceService) public: - RemoteLinuxCheckForFreeDiskSpaceService() {} + CheckForFreeDiskSpaceService() {} void setPathToCheck(const QString &path); void setRequiredSpaceInBytes(quint64 sizeInBytes); @@ -65,17 +63,17 @@ private: quint64 m_requiredSpaceInBytes = 0; }; -void RemoteLinuxCheckForFreeDiskSpaceService::setPathToCheck(const QString &path) +void CheckForFreeDiskSpaceService::setPathToCheck(const QString &path) { m_pathToCheck = path; } -void RemoteLinuxCheckForFreeDiskSpaceService::setRequiredSpaceInBytes(quint64 sizeInBytes) +void CheckForFreeDiskSpaceService::setRequiredSpaceInBytes(quint64 sizeInBytes) { m_requiredSpaceInBytes = sizeInBytes; } -void RemoteLinuxCheckForFreeDiskSpaceService::doDeploy() +void CheckForFreeDiskSpaceService::doDeploy() { auto cleanup = qScopeGuard([this] { setFinished(); }); const FilePath path = deviceConfiguration()->filePath(m_pathToCheck); @@ -104,7 +102,7 @@ void RemoteLinuxCheckForFreeDiskSpaceService::doDeploy() handleDeploymentDone(); } -CheckResult RemoteLinuxCheckForFreeDiskSpaceService::isDeploymentPossible() const +CheckResult CheckForFreeDiskSpaceService::isDeploymentPossible() const { if (!m_pathToCheck.startsWith('/')) { return CheckResult::failure( @@ -115,13 +113,11 @@ CheckResult RemoteLinuxCheckForFreeDiskSpaceService::isDeploymentPossible() cons return AbstractRemoteLinuxDeployService::isDeploymentPossible(); } -// RemoteLinuxCheckForFreeDiskSpaceStep - -RemoteLinuxCheckForFreeDiskSpaceStep::RemoteLinuxCheckForFreeDiskSpaceStep +CheckForFreeDiskSpaceStep::CheckForFreeDiskSpaceStep (BuildStepList *bsl, Id id) : AbstractRemoteLinuxDeployStep(bsl, id) { - auto service = createDeployService(); + auto service = createDeployService(); auto pathToCheckAspect = addAspect(); pathToCheckAspect->setSettingsKey("RemoteLinux.CheckForFreeDiskSpaceStep.PathToCheck"); @@ -144,14 +140,12 @@ RemoteLinuxCheckForFreeDiskSpaceStep::RemoteLinuxCheckForFreeDiskSpaceStep }); } -RemoteLinuxCheckForFreeDiskSpaceStep::~RemoteLinuxCheckForFreeDiskSpaceStep() = default; - -Id RemoteLinuxCheckForFreeDiskSpaceStep::stepId() +Id CheckForFreeDiskSpaceStep::stepId() { return "RemoteLinux.CheckForFreeDiskSpaceStep"; } -QString RemoteLinuxCheckForFreeDiskSpaceStep::displayName() +QString CheckForFreeDiskSpaceStep::displayName() { return tr("Check for free disk space"); } diff --git a/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.h b/src/plugins/remotelinux/checkforfreediskspacestep.h similarity index 84% rename from src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.h rename to src/plugins/remotelinux/checkforfreediskspacestep.h index 723b4f19b32..1bbdacfa61c 100644 --- a/src/plugins/remotelinux/remotelinuxcheckforfreediskspacestep.h +++ b/src/plugins/remotelinux/checkforfreediskspacestep.h @@ -29,13 +29,12 @@ namespace RemoteLinux { -class REMOTELINUX_EXPORT RemoteLinuxCheckForFreeDiskSpaceStep : public AbstractRemoteLinuxDeployStep +class REMOTELINUX_EXPORT CheckForFreeDiskSpaceStep : public AbstractRemoteLinuxDeployStep { Q_OBJECT public: - RemoteLinuxCheckForFreeDiskSpaceStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id); - ~RemoteLinuxCheckForFreeDiskSpaceStep() override; + CheckForFreeDiskSpaceStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id); static Utils::Id stepId(); static QString displayName(); diff --git a/src/plugins/remotelinux/remotelinux.qbs b/src/plugins/remotelinux/remotelinux.qbs index 3ddf4537343..858fd5bb8a8 100644 --- a/src/plugins/remotelinux/remotelinux.qbs +++ b/src/plugins/remotelinux/remotelinux.qbs @@ -21,6 +21,8 @@ Project { "abstractremotelinuxdeploystep.h", "deploymenttimeinfo.cpp", "deploymenttimeinfo.h", + "checkforfreediskspacestep.cpp", + "checkforfreediskspacestep.h", "customcommanddeploystep.cpp", "customcommanddeploystep.h", "genericdirectuploadservice.cpp", @@ -49,8 +51,6 @@ Project { "remotelinux.qrc", "remotelinux_constants.h", "remotelinux_export.h", - "remotelinuxcheckforfreediskspacestep.cpp", - "remotelinuxcheckforfreediskspacestep.h", "remotelinuxcustomrunconfiguration.cpp", "remotelinuxcustomrunconfiguration.h", "remotelinuxdebugsupport.cpp", diff --git a/src/plugins/remotelinux/remotelinuxdeployconfiguration.cpp b/src/plugins/remotelinux/remotelinuxdeployconfiguration.cpp index b248d53f918..ed8f0d0d9bb 100644 --- a/src/plugins/remotelinux/remotelinuxdeployconfiguration.cpp +++ b/src/plugins/remotelinux/remotelinuxdeployconfiguration.cpp @@ -25,9 +25,9 @@ #include "remotelinuxdeployconfiguration.h" +#include "checkforfreediskspacestep.h" #include "genericdirectuploadstep.h" #include "makeinstallstep.h" -#include "remotelinuxcheckforfreediskspacestep.h" #include "killappstep.h" #include "remotelinux_constants.h" #include "rsyncdeploystep.h" @@ -76,7 +76,7 @@ RemoteLinuxDeployConfigurationFactory::RemoteLinuxDeployConfigurationFactory() }); addInitialStep(MakeInstallStep::stepId(), needsMakeInstall); - addInitialStep(RemoteLinuxCheckForFreeDiskSpaceStep::stepId()); + addInitialStep(CheckForFreeDiskSpaceStep::stepId()); addInitialStep(KillAppStep::stepId()); addInitialStep(RsyncDeployStep::stepId(), [](Target *target) { auto device = DeviceKitAspect::device(target->kit()); diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp index 1c1c6e01ff4..4affcd2aef4 100644 --- a/src/plugins/remotelinux/remotelinuxplugin.cpp +++ b/src/plugins/remotelinux/remotelinuxplugin.cpp @@ -25,13 +25,13 @@ #include "remotelinuxplugin.h" +#include "checkforfreediskspacestep.h" #include "customcommanddeploystep.h" #include "genericdirectuploadstep.h" #include "killappstep.h" #include "linuxdevice.h" #include "makeinstallstep.h" #include "remotelinux_constants.h" -#include "remotelinuxcheckforfreediskspacestep.h" #include "remotelinuxdeployconfiguration.h" #include "remotelinuxqmltoolingsupport.h" #include "remotelinuxcustomrunconfiguration.h" @@ -79,8 +79,7 @@ public: GenericDeployStepFactory genericDirectUploadStepFactory; GenericDeployStepFactory rsyncDeployStepFactory; GenericDeployStepFactory customCommandDeployStepFactory; - GenericDeployStepFactory - checkForFreeDiskSpaceStepFactory; + GenericDeployStepFactory checkForFreeDiskSpaceStepFactory; GenericDeployStepFactory killAppStepFactory; GenericDeployStepFactory makeInstallStepFactory; From 6698c4dff03c5cbddf162a623e4eb0f7a451b312 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 27 May 2022 15:41:57 +0200 Subject: [PATCH 10/12] RemoteLinux: Add more forward declarations Change-Id: Ie1182248e3b423ce3b85a2baf0c2d7be74de1126 Reviewed-by: Christian Kandeler Reviewed-by: Reviewed-by: Qt CI Bot --- src/plugins/boot2qt/qdbmakedefaultappstep.cpp | 1 + src/plugins/boot2qt/qdbstopapplicationstep.cpp | 1 + .../remotelinux/abstractremotelinuxdeployservice.cpp | 1 + .../remotelinux/abstractremotelinuxdeploystep.cpp | 1 - src/plugins/remotelinux/abstractremotelinuxdeploystep.h | 5 +++-- src/plugins/remotelinux/checkforfreediskspacestep.h | 2 ++ src/plugins/remotelinux/customcommanddeploystep.cpp | 1 + src/plugins/remotelinux/customcommanddeploystep.h | 2 ++ src/plugins/remotelinux/deploymenttimeinfo.h | 4 ++++ src/plugins/remotelinux/filesystemaccess_test.h | 2 -- src/plugins/remotelinux/genericdirectuploadservice.h | 9 ++++++--- src/plugins/remotelinux/genericdirectuploadstep.h | 3 ++- .../remotelinux/genericlinuxdeviceconfigurationwidget.h | 4 ++-- .../genericlinuxdeviceconfigurationwizardpages.h | 3 ++- src/plugins/remotelinux/killappstep.cpp | 1 + src/plugins/remotelinux/killappstep.h | 2 ++ src/plugins/remotelinux/linuxdevicetester.h | 2 +- src/plugins/remotelinux/remotelinuxdeployconfiguration.h | 3 --- .../remotelinux/remotelinuxenvironmentaspectwidget.cpp | 2 +- .../remotelinux/remotelinuxenvironmentaspectwidget.h | 8 +++++--- src/plugins/remotelinux/remotelinuxrunconfiguration.h | 2 -- src/plugins/remotelinux/rsyncdeploystep.h | 3 ++- src/plugins/remotelinux/sshkeycreationdialog.h | 6 ++---- src/plugins/remotelinux/tarpackagecreationstep.h | 7 +++---- src/plugins/remotelinux/tarpackagedeploystep.cpp | 1 + 25 files changed, 45 insertions(+), 31 deletions(-) diff --git a/src/plugins/boot2qt/qdbmakedefaultappstep.cpp b/src/plugins/boot2qt/qdbmakedefaultappstep.cpp index 59392cb4aa8..008230028a9 100644 --- a/src/plugins/boot2qt/qdbmakedefaultappstep.cpp +++ b/src/plugins/boot2qt/qdbmakedefaultappstep.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include diff --git a/src/plugins/boot2qt/qdbstopapplicationstep.cpp b/src/plugins/boot2qt/qdbstopapplicationstep.cpp index 58071f4f8d5..106685b4268 100644 --- a/src/plugins/boot2qt/qdbstopapplicationstep.cpp +++ b/src/plugins/boot2qt/qdbstopapplicationstep.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include diff --git a/src/plugins/remotelinux/abstractremotelinuxdeployservice.cpp b/src/plugins/remotelinux/abstractremotelinuxdeployservice.cpp index f4ff1cef251..aee4d2eec53 100644 --- a/src/plugins/remotelinux/abstractremotelinuxdeployservice.cpp +++ b/src/plugins/remotelinux/abstractremotelinuxdeployservice.cpp @@ -24,6 +24,7 @@ ****************************************************************************/ #include "abstractremotelinuxdeployservice.h" + #include "deploymenttimeinfo.h" #include diff --git a/src/plugins/remotelinux/abstractremotelinuxdeploystep.cpp b/src/plugins/remotelinux/abstractremotelinuxdeploystep.cpp index ba6c827d87a..b23f7244337 100644 --- a/src/plugins/remotelinux/abstractremotelinuxdeploystep.cpp +++ b/src/plugins/remotelinux/abstractremotelinuxdeploystep.cpp @@ -26,7 +26,6 @@ #include "abstractremotelinuxdeploystep.h" #include "abstractremotelinuxdeployservice.h" -#include "remotelinuxdeployconfiguration.h" #include #include diff --git a/src/plugins/remotelinux/abstractremotelinuxdeploystep.h b/src/plugins/remotelinux/abstractremotelinuxdeploystep.h index 14d84a4f59e..2f72c68f559 100644 --- a/src/plugins/remotelinux/abstractremotelinuxdeploystep.h +++ b/src/plugins/remotelinux/abstractremotelinuxdeploystep.h @@ -27,12 +27,13 @@ #include "remotelinux_export.h" -#include "abstractremotelinuxdeployservice.h" - #include namespace RemoteLinux { +class AbstractRemoteLinuxDeployService; +class CheckResult; + namespace Internal { class AbstractRemoteLinuxDeployStepPrivate; } class REMOTELINUX_EXPORT AbstractRemoteLinuxDeployStep : public ProjectExplorer::BuildStep diff --git a/src/plugins/remotelinux/checkforfreediskspacestep.h b/src/plugins/remotelinux/checkforfreediskspacestep.h index 1bbdacfa61c..e1ff4c3765e 100644 --- a/src/plugins/remotelinux/checkforfreediskspacestep.h +++ b/src/plugins/remotelinux/checkforfreediskspacestep.h @@ -25,6 +25,8 @@ #pragma once +#include "remotelinux_export.h" + #include "abstractremotelinuxdeploystep.h" namespace RemoteLinux { diff --git a/src/plugins/remotelinux/customcommanddeploystep.cpp b/src/plugins/remotelinux/customcommanddeploystep.cpp index 6b5b91ef1cb..318d5cd7a47 100644 --- a/src/plugins/remotelinux/customcommanddeploystep.cpp +++ b/src/plugins/remotelinux/customcommanddeploystep.cpp @@ -25,6 +25,7 @@ #include "customcommanddeploystep.h" +#include "abstractremotelinuxdeployservice.h" #include "remotelinux_constants.h" #include diff --git a/src/plugins/remotelinux/customcommanddeploystep.h b/src/plugins/remotelinux/customcommanddeploystep.h index 797fc90606d..0a9503d666b 100644 --- a/src/plugins/remotelinux/customcommanddeploystep.h +++ b/src/plugins/remotelinux/customcommanddeploystep.h @@ -25,6 +25,8 @@ #pragma once +#include "remotelinux_export.h" + #include "abstractremotelinuxdeploystep.h" namespace RemoteLinux { diff --git a/src/plugins/remotelinux/deploymenttimeinfo.h b/src/plugins/remotelinux/deploymenttimeinfo.h index 01b64055038..202d97aebbe 100644 --- a/src/plugins/remotelinux/deploymenttimeinfo.h +++ b/src/plugins/remotelinux/deploymenttimeinfo.h @@ -27,6 +27,10 @@ #include +QT_BEGIN_NAMESPACE +class QDateTime; +QT_END_NAMESPACE + namespace ProjectExplorer { class DeployableFile; class Kit; diff --git a/src/plugins/remotelinux/filesystemaccess_test.h b/src/plugins/remotelinux/filesystemaccess_test.h index 64f07b289ce..652a9ee4528 100644 --- a/src/plugins/remotelinux/filesystemaccess_test.h +++ b/src/plugins/remotelinux/filesystemaccess_test.h @@ -27,8 +27,6 @@ #include -#include - namespace RemoteLinux { namespace Internal { diff --git a/src/plugins/remotelinux/genericdirectuploadservice.h b/src/plugins/remotelinux/genericdirectuploadservice.h index ffbd9fc866d..a426481f1f1 100644 --- a/src/plugins/remotelinux/genericdirectuploadservice.h +++ b/src/plugins/remotelinux/genericdirectuploadservice.h @@ -25,13 +25,16 @@ #pragma once -#include "abstractremotelinuxdeployservice.h" #include "remotelinux_export.h" +#include "abstractremotelinuxdeployservice.h" + #include -QT_FORWARD_DECLARE_CLASS(QDateTime) -QT_FORWARD_DECLARE_CLASS(QString) +QT_BEGIN_NAMESPACE +class QDateTime; +class QString; +QT_END_NAMESPACE namespace ProjectExplorer { class DeployableFile; } namespace Utils { class QtcProcess; } diff --git a/src/plugins/remotelinux/genericdirectuploadstep.h b/src/plugins/remotelinux/genericdirectuploadstep.h index ef5e429fb8c..595d74c8547 100644 --- a/src/plugins/remotelinux/genericdirectuploadstep.h +++ b/src/plugins/remotelinux/genericdirectuploadstep.h @@ -25,9 +25,10 @@ #pragma once -#include "abstractremotelinuxdeploystep.h" #include "remotelinux_export.h" +#include "abstractremotelinuxdeploystep.h" + namespace RemoteLinux { class REMOTELINUX_EXPORT GenericDirectUploadStep : public AbstractRemoteLinuxDeployStep diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwidget.h b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwidget.h index fba1e2d4971..241347aa1bd 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwidget.h +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwidget.h @@ -25,10 +25,10 @@ #pragma once -#include - #include "remotelinux_export.h" +#include + namespace Utils { class FilePath; } namespace RemoteLinux { diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.h b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.h index a16e846fcfb..2fa8e0d01cf 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.h +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwizardpages.h @@ -25,9 +25,10 @@ #pragma once -#include "linuxdevice.h" #include "remotelinux_export.h" +#include "linuxdevice.h" + #include namespace RemoteLinux { diff --git a/src/plugins/remotelinux/killappstep.cpp b/src/plugins/remotelinux/killappstep.cpp index cb5bc06a79a..03d40e31666 100644 --- a/src/plugins/remotelinux/killappstep.cpp +++ b/src/plugins/remotelinux/killappstep.cpp @@ -25,6 +25,7 @@ #include "killappstep.h" +#include "abstractremotelinuxdeployservice.h" #include "remotelinux_constants.h" #include diff --git a/src/plugins/remotelinux/killappstep.h b/src/plugins/remotelinux/killappstep.h index 62fbc81643c..f26161e26ad 100644 --- a/src/plugins/remotelinux/killappstep.h +++ b/src/plugins/remotelinux/killappstep.h @@ -25,6 +25,8 @@ #pragma once +#include "remotelinux_export.h" + #include "abstractremotelinuxdeploystep.h" namespace RemoteLinux { diff --git a/src/plugins/remotelinux/linuxdevicetester.h b/src/plugins/remotelinux/linuxdevicetester.h index 2906a51b67d..890484a8705 100644 --- a/src/plugins/remotelinux/linuxdevicetester.h +++ b/src/plugins/remotelinux/linuxdevicetester.h @@ -27,9 +27,9 @@ #include "remotelinux_export.h" -#include #include +namespace ProjectExplorer { enum class FileTransferMethod; } namespace Utils { class ProcessResultData; } namespace RemoteLinux { diff --git a/src/plugins/remotelinux/remotelinuxdeployconfiguration.h b/src/plugins/remotelinux/remotelinuxdeployconfiguration.h index 723c6b30380..264d28e1e40 100644 --- a/src/plugins/remotelinux/remotelinuxdeployconfiguration.h +++ b/src/plugins/remotelinux/remotelinuxdeployconfiguration.h @@ -25,9 +25,6 @@ #pragma once -#include "remotelinux_export.h" - -#include #include namespace RemoteLinux { diff --git a/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp b/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp index 53b4aa8fee5..a3016371044 100644 --- a/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp +++ b/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.cpp @@ -26,7 +26,7 @@ #include "remotelinuxenvironmentaspectwidget.h" #include "linuxdevice.h" -#include "remotelinuxrunconfiguration.h" +#include "remotelinuxenvironmentaspect.h" #include "remotelinuxenvironmentreader.h" #include diff --git a/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.h b/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.h index e31c85b9a31..1f65d594234 100644 --- a/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.h +++ b/src/plugins/remotelinux/remotelinuxenvironmentaspectwidget.h @@ -25,14 +25,16 @@ #pragma once -#include "remotelinuxenvironmentaspect.h" - #include -QT_FORWARD_DECLARE_CLASS(QPushButton) +QT_BEGIN_NAMESPACE +class QPushButton; +QT_END_NAMESPACE namespace RemoteLinux { +class RemoteLinuxEnvironmentAspect; + namespace Internal { class RemoteLinuxEnvironmentReader; } class RemoteLinuxEnvironmentAspectWidget : public ProjectExplorer::EnvironmentAspectWidget diff --git a/src/plugins/remotelinux/remotelinuxrunconfiguration.h b/src/plugins/remotelinux/remotelinuxrunconfiguration.h index 59951dbe457..eceeb5b6267 100644 --- a/src/plugins/remotelinux/remotelinuxrunconfiguration.h +++ b/src/plugins/remotelinux/remotelinuxrunconfiguration.h @@ -25,8 +25,6 @@ #pragma once -#include "remotelinux_export.h" - #include namespace RemoteLinux { diff --git a/src/plugins/remotelinux/rsyncdeploystep.h b/src/plugins/remotelinux/rsyncdeploystep.h index 2a85a216a56..76373a2ef86 100644 --- a/src/plugins/remotelinux/rsyncdeploystep.h +++ b/src/plugins/remotelinux/rsyncdeploystep.h @@ -25,9 +25,10 @@ #pragma once -#include "abstractremotelinuxdeploystep.h" #include "remotelinux_export.h" +#include "abstractremotelinuxdeploystep.h" + namespace RemoteLinux { class REMOTELINUX_EXPORT RsyncDeployStep : public AbstractRemoteLinuxDeployStep diff --git a/src/plugins/remotelinux/sshkeycreationdialog.h b/src/plugins/remotelinux/sshkeycreationdialog.h index a7efd3c6610..859ac326a67 100644 --- a/src/plugins/remotelinux/sshkeycreationdialog.h +++ b/src/plugins/remotelinux/sshkeycreationdialog.h @@ -25,12 +25,10 @@ #pragma once -#include "remotelinux_export.h" - -#include - #include +namespace Utils { class FilePath; } + namespace RemoteLinux { namespace Ui { class SshKeyCreationDialog; } diff --git a/src/plugins/remotelinux/tarpackagecreationstep.h b/src/plugins/remotelinux/tarpackagecreationstep.h index 33a7b4358e6..3c60815e5f3 100644 --- a/src/plugins/remotelinux/tarpackagecreationstep.h +++ b/src/plugins/remotelinux/tarpackagecreationstep.h @@ -25,13 +25,12 @@ #pragma once -#include "abstractpackagingstep.h" -#include "deploymenttimeinfo.h" #include "remotelinux_export.h" -#include +#include "abstractpackagingstep.h" +#include "deploymenttimeinfo.h" -#include +#include QT_BEGIN_NAMESPACE class QFile; diff --git a/src/plugins/remotelinux/tarpackagedeploystep.cpp b/src/plugins/remotelinux/tarpackagedeploystep.cpp index 7247d165c4f..db8fdec076d 100644 --- a/src/plugins/remotelinux/tarpackagedeploystep.cpp +++ b/src/plugins/remotelinux/tarpackagedeploystep.cpp @@ -25,6 +25,7 @@ #include "tarpackagedeploystep.h" +#include "abstractremotelinuxdeployservice.h" #include "remotelinux_constants.h" #include "tarpackagecreationstep.h" From 57e705b616f8d412001317417cf5b71b9cb8656e Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 27 May 2022 16:51:04 +0200 Subject: [PATCH 11/12] Merge AbstractPackaginsStep with TarPackageCreationStep Change-Id: I754d46df144fa4cc4d9715a22b85b12e38828ff6 Reviewed-by: Christian Kandeler Reviewed-by: Qt CI Bot Reviewed-by: --- src/plugins/remotelinux/CMakeLists.txt | 1 - .../remotelinux/abstractpackagingstep.cpp | 148 ------- .../remotelinux/abstractpackagingstep.h | 71 ---- src/plugins/remotelinux/remotelinux.qbs | 2 - .../remotelinux/tarpackagecreationstep.cpp | 364 ++++++++++-------- .../remotelinux/tarpackagecreationstep.h | 47 +-- 6 files changed, 227 insertions(+), 406 deletions(-) delete mode 100644 src/plugins/remotelinux/abstractpackagingstep.cpp delete mode 100644 src/plugins/remotelinux/abstractpackagingstep.h diff --git a/src/plugins/remotelinux/CMakeLists.txt b/src/plugins/remotelinux/CMakeLists.txt index 8c90671faa4..2de46781890 100644 --- a/src/plugins/remotelinux/CMakeLists.txt +++ b/src/plugins/remotelinux/CMakeLists.txt @@ -2,7 +2,6 @@ add_qtc_plugin(RemoteLinux DEPENDS QmlDebug PLUGIN_DEPENDS Core Debugger ProjectExplorer SOURCES - abstractpackagingstep.cpp abstractpackagingstep.h abstractremotelinuxdeployservice.cpp abstractremotelinuxdeployservice.h abstractremotelinuxdeploystep.cpp abstractremotelinuxdeploystep.h checkforfreediskspacestep.cpp checkforfreediskspacestep.h diff --git a/src/plugins/remotelinux/abstractpackagingstep.cpp b/src/plugins/remotelinux/abstractpackagingstep.cpp deleted file mode 100644 index 2c31b8aa75f..00000000000 --- a/src/plugins/remotelinux/abstractpackagingstep.cpp +++ /dev/null @@ -1,148 +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 "abstractpackagingstep.h" - -#include -#include -#include -#include -#include - -#include - -using namespace ProjectExplorer; -using namespace Utils; - -namespace RemoteLinux { -namespace Internal { - -class AbstractPackagingStepPrivate -{ -public: - FilePath cachedPackageFilePath; - FilePath cachedPackageDirectory; - bool deploymentDataModified = false; -}; - -} // namespace Internal - -AbstractPackagingStep::AbstractPackagingStep(BuildStepList *bsl, Utils::Id id) - : BuildStep(bsl, id) -{ - d = new Internal::AbstractPackagingStepPrivate; - - connect(target(), &Target::deploymentDataChanged, - this, &AbstractPackagingStep::setDeploymentDataModified); - setDeploymentDataModified(); - - connect(this, &AbstractPackagingStep::unmodifyDeploymentData, - this, &AbstractPackagingStep::setDeploymentDataUnmodified); -} - -AbstractPackagingStep::~AbstractPackagingStep() -{ - delete d; -} - -FilePath AbstractPackagingStep::cachedPackageFilePath() const -{ - return d->cachedPackageFilePath; -} - -FilePath AbstractPackagingStep::packageFilePath() const -{ - if (packageDirectory().isEmpty()) - return {}; - return packageDirectory().pathAppended(packageFileName()); -} - -FilePath AbstractPackagingStep::cachedPackageDirectory() const -{ - return d->cachedPackageDirectory; -} - -FilePath AbstractPackagingStep::packageDirectory() const -{ - return buildDirectory(); -} - -bool AbstractPackagingStep::isPackagingNeeded() const -{ - const FilePath packagePath = packageFilePath(); - if (!packagePath.exists() || d->deploymentDataModified) - return true; - - const DeploymentData &dd = target()->deploymentData(); - for (int i = 0; i < dd.fileCount(); ++i) { - if (dd.fileAt(i).localFilePath().isNewerThan(packagePath.lastModified())) - return true; - } - - return false; -} - -bool AbstractPackagingStep::init() -{ - d->cachedPackageDirectory = packageDirectory(); - d->cachedPackageFilePath = packageFilePath(); - return true; -} - -void AbstractPackagingStep::setPackagingStarted() -{ -} - -// called in ::run thread -void AbstractPackagingStep::setPackagingFinished(bool success) -{ - if (success) - emit unmodifyDeploymentData(); -} - -// called in gui thread -void AbstractPackagingStep::setDeploymentDataUnmodified() -{ - d->deploymentDataModified = false; -} - -void AbstractPackagingStep::setDeploymentDataModified() -{ - d->deploymentDataModified = true; -} - -void AbstractPackagingStep::raiseError(const QString &errorMessage) -{ - emit addTask(DeploymentTask(Task::Error, errorMessage)); - emit addOutput(errorMessage, BuildStep::OutputFormat::Stderr); -} - -void AbstractPackagingStep::raiseWarning(const QString &warningMessage) -{ - emit addTask(DeploymentTask(Task::Warning, warningMessage)); - emit addOutput(warningMessage, OutputFormat::ErrorMessage); -} - -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/abstractpackagingstep.h b/src/plugins/remotelinux/abstractpackagingstep.h deleted file mode 100644 index 681ba70ac00..00000000000 --- a/src/plugins/remotelinux/abstractpackagingstep.h +++ /dev/null @@ -1,71 +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 { - -namespace Internal { class AbstractPackagingStepPrivate; } - -class REMOTELINUX_EXPORT AbstractPackagingStep : public ProjectExplorer::BuildStep -{ - Q_OBJECT - -public: - explicit AbstractPackagingStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id); - ~AbstractPackagingStep() override; - - Utils::FilePath packageFilePath() const; - Utils::FilePath cachedPackageFilePath() const; - bool init() override; - -signals: - void unmodifyDeploymentData(); - -protected: - void setPackagingStarted(); - void setPackagingFinished(bool success); - - void raiseError(const QString &errorMessage); - void raiseWarning(const QString &warningMessage); - Utils::FilePath cachedPackageDirectory() const; - Utils::FilePath packageDirectory() const; - - virtual bool isPackagingNeeded() const; - -private: - void setDeploymentDataUnmodified(); - void setDeploymentDataModified(); - - virtual QString packageFileName() const = 0; - - Internal::AbstractPackagingStepPrivate *d; -}; - -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/remotelinux.qbs b/src/plugins/remotelinux/remotelinux.qbs index 858fd5bb8a8..859c8f249d7 100644 --- a/src/plugins/remotelinux/remotelinux.qbs +++ b/src/plugins/remotelinux/remotelinux.qbs @@ -13,8 +13,6 @@ Project { Depends { name: "ProjectExplorer" } files: [ - "abstractpackagingstep.cpp", - "abstractpackagingstep.h", "abstractremotelinuxdeployservice.cpp", "abstractremotelinuxdeployservice.h", "abstractremotelinuxdeploystep.cpp", diff --git a/src/plugins/remotelinux/tarpackagecreationstep.cpp b/src/plugins/remotelinux/tarpackagecreationstep.cpp index efae933ce6e..23eb9745bd7 100644 --- a/src/plugins/remotelinux/tarpackagecreationstep.cpp +++ b/src/plugins/remotelinux/tarpackagecreationstep.cpp @@ -25,6 +25,7 @@ #include "tarpackagecreationstep.h" +#include "deploymenttimeinfo.h" #include "remotelinux_constants.h" #include @@ -43,7 +44,7 @@ using namespace ProjectExplorer; using namespace Utils; namespace RemoteLinux { -namespace { + const char IgnoreMissingFilesKey[] = "RemoteLinux.TarPackageCreationStep.IgnoreMissingFiles"; const char IncrementalDeploymentKey[] = "RemoteLinux.TarPackageCreationStep.IncrementalDeployment"; @@ -68,20 +69,40 @@ struct TarFileHeader { char padding[12]; }; -} // Anonymous namespace. +namespace Internal { -TarPackageCreationStep::TarPackageCreationStep(BuildStepList *bsl, Utils::Id id) - : AbstractPackagingStep(bsl, id) +class TarPackageCreationStepPrivate { - m_ignoreMissingFilesAspect = addAspect(); - m_ignoreMissingFilesAspect->setLabel(tr("Ignore missing files"), - BoolAspect::LabelPlacement::AtCheckBox); - m_ignoreMissingFilesAspect->setSettingsKey(IgnoreMissingFilesKey); +public: + FilePath m_cachedPackageFilePath; + bool m_deploymentDataModified = false; + DeploymentTimeInfo m_deployTimes; + BoolAspect *m_incrementalDeploymentAspect = nullptr; + BoolAspect *m_ignoreMissingFilesAspect = nullptr; + bool m_packagingNeeded = false; + QList m_files; +}; - m_incrementalDeploymentAspect = addAspect(); - m_incrementalDeploymentAspect->setLabel(tr("Package modified files only"), +} // namespace Internal + +TarPackageCreationStep::TarPackageCreationStep(BuildStepList *bsl, Id id) + : BuildStep(bsl, id) + , d(new Internal::TarPackageCreationStepPrivate) +{ + connect(target(), &Target::deploymentDataChanged, this, [this] { + d->m_deploymentDataModified = true; + }); + d->m_deploymentDataModified = true; + + d->m_ignoreMissingFilesAspect = addAspect(); + d->m_ignoreMissingFilesAspect->setLabel(tr("Ignore missing files"), + BoolAspect::LabelPlacement::AtCheckBox); + d->m_ignoreMissingFilesAspect->setSettingsKey(IgnoreMissingFilesKey); + + d->m_incrementalDeploymentAspect = addAspect(); + d->m_incrementalDeploymentAspect->setLabel(tr("Package modified files only"), BoolAspect::LabelPlacement::AtCheckBox); - m_incrementalDeploymentAspect->setSettingsKey(IncrementalDeploymentKey); + d->m_incrementalDeploymentAspect->setSettingsKey(IncrementalDeploymentKey); setSummaryUpdater([this] { FilePath path = packageFilePath(); @@ -92,13 +113,30 @@ TarPackageCreationStep::TarPackageCreationStep(BuildStepList *bsl, Utils::Id id) }); } +TarPackageCreationStep::~TarPackageCreationStep() = default; + +Utils::Id TarPackageCreationStep::stepId() +{ + return Constants::TarPackageCreationStepId; +} + +QString TarPackageCreationStep::displayName() +{ + return tr("Create tarball"); +} + +FilePath TarPackageCreationStep::packageFilePath() const +{ + if (buildDirectory().isEmpty()) + return {}; + const QString packageFileName = project()->displayName() + QLatin1String(".tar"); + return buildDirectory().pathAppended(packageFileName); +} + bool TarPackageCreationStep::init() { - if (!AbstractPackagingStep::init()) - return false; - - m_packagingNeeded = isPackagingNeeded(); - + d->m_cachedPackageFilePath = packageFilePath(); + d->m_packagingNeeded = isPackagingNeeded(); return true; } @@ -107,14 +145,76 @@ void TarPackageCreationStep::doRun() runInThread([this] { return runImpl(); }); } +bool TarPackageCreationStep::fromMap(const QVariantMap &map) +{ + if (!BuildStep::fromMap(map)) + return false; + d->m_deployTimes.importDeployTimes(map); + return true; +} + +QVariantMap TarPackageCreationStep::toMap() const +{ + QVariantMap map = BuildStep::toMap(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + map.insert(d->m_deployTimes.exportDeployTimes()); +#else + map.unite(d->m_deployTimes.exportDeployTimes()); +#endif + return map; +} + +void TarPackageCreationStep::raiseError(const QString &errorMessage) +{ + emit addTask(DeploymentTask(Task::Error, errorMessage)); + emit addOutput(errorMessage, BuildStep::OutputFormat::Stderr); +} + +void TarPackageCreationStep::raiseWarning(const QString &warningMessage) +{ + emit addTask(DeploymentTask(Task::Warning, warningMessage)); + emit addOutput(warningMessage, OutputFormat::ErrorMessage); +} + +bool TarPackageCreationStep::isPackagingNeeded() const +{ + const FilePath packagePath = packageFilePath(); + if (!packagePath.exists() || d->m_deploymentDataModified) + return true; + + const DeploymentData &dd = target()->deploymentData(); + for (int i = 0; i < dd.fileCount(); ++i) { + if (dd.fileAt(i).localFilePath().isNewerThan(packagePath.lastModified())) + return true; + } + + return false; +} + +void TarPackageCreationStep::deployFinished(bool success) +{ + disconnect(BuildManager::instance(), &BuildManager::buildQueueFinished, + this, &TarPackageCreationStep::deployFinished); + + if (!success) + return; + + const Kit *kit = target()->kit(); + + // Store files that have been tar'd and successfully deployed + const auto files = d->m_files; + for (const DeployableFile &file : files) + d->m_deployTimes.saveDeploymentTimeStamp(file, kit, QDateTime()); +} + void TarPackageCreationStep::addNeededDeploymentFiles( const ProjectExplorer::DeployableFile &deployable, const ProjectExplorer::Kit *kit) { const QFileInfo fileInfo = deployable.localFilePath().toFileInfo(); if (!fileInfo.isDir()) { - if (m_deployTimes.hasLocalFileChanged(deployable, kit)) - m_files << deployable; + if (d->m_deployTimes.hasLocalFileChanged(deployable, kit)) + d->m_files << deployable; return; } @@ -122,7 +222,7 @@ void TarPackageCreationStep::addNeededDeploymentFiles( .entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); if (files.isEmpty()) { - m_files << deployable; + d->m_files << deployable; return; } @@ -136,16 +236,43 @@ void TarPackageCreationStep::addNeededDeploymentFiles( } } +bool TarPackageCreationStep::runImpl() +{ + const QList &files = target()->deploymentData().allFiles(); + + if (d->m_incrementalDeploymentAspect->value()) { + d->m_files.clear(); + for (const DeployableFile &file : files) + addNeededDeploymentFiles(file, kit()); + } else { + d->m_files = files; + } + + const bool success = doPackage(); + + if (success) { + d->m_deploymentDataModified = false; + emit addOutput(tr("Packaging finished successfully."), OutputFormat::NormalMessage); + } else { + emit addOutput(tr("Packaging failed."), OutputFormat::ErrorMessage); + } + + connect(BuildManager::instance(), &BuildManager::buildQueueFinished, + this, &TarPackageCreationStep::deployFinished); + + return success; +} + bool TarPackageCreationStep::doPackage() { emit addOutput(tr("Creating tarball..."), OutputFormat::NormalMessage); - if (!m_packagingNeeded) { + if (!d->m_packagingNeeded) { emit addOutput(tr("Tarball up to date, skipping packaging."), OutputFormat::NormalMessage); return true; } // TODO: Optimization: Only package changed files - const FilePath tarFilePath = cachedPackageFilePath(); + const FilePath tarFilePath = d->m_cachedPackageFilePath; QFile tarFile(tarFilePath.toString()); if (!tarFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { @@ -154,7 +281,7 @@ bool TarPackageCreationStep::doPackage() return false; } - foreach (const DeployableFile &d, m_files) { + for (const DeployableFile &d : qAsConst(d->m_files)) { if (d.remoteDirectory().isEmpty()) { emit addOutput(tr("No remote path specified for file \"%1\", skipping.") .arg(d.localFilePath().toUserOutput()), OutputFormat::ErrorMessage); @@ -177,66 +304,6 @@ bool TarPackageCreationStep::doPackage() return true; } -bool TarPackageCreationStep::appendFile(QFile &tarFile, const QFileInfo &fileInfo, - const QString &remoteFilePath) -{ - if (!writeHeader(tarFile, fileInfo, remoteFilePath)) - return false; - if (fileInfo.isDir()) { - QDir dir(fileInfo.absoluteFilePath()); - foreach (const QString &fileName, - dir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) { - const QString thisLocalFilePath = dir.path() + QLatin1Char('/') + fileName; - const QString thisRemoteFilePath = remoteFilePath + QLatin1Char('/') + fileName; - if (!appendFile(tarFile, QFileInfo(thisLocalFilePath), thisRemoteFilePath)) - return false; - } - return true; - } - - const QString nativePath = QDir::toNativeSeparators(fileInfo.filePath()); - QFile file(fileInfo.filePath()); - if (!file.open(QIODevice::ReadOnly)) { - const QString message = tr("Error reading file \"%1\": %2.") - .arg(nativePath, file.errorString()); - if (m_ignoreMissingFilesAspect->value()) { - raiseWarning(message); - return true; - } else { - raiseError(message); - return false; - } - } - - const int chunkSize = 1024*1024; - - emit addOutput(tr("Adding file \"%1\" to tarball...").arg(nativePath), - OutputFormat::NormalMessage); - - // TODO: Wasteful. Work with fixed-size buffer. - while (!file.atEnd() && file.error() == QFile::NoError && tarFile.error() == QFile::NoError) { - const QByteArray data = file.read(chunkSize); - tarFile.write(data); - if (isCanceled()) - return false; - } - if (file.error() != QFile::NoError) { - raiseError(tr("Error reading file \"%1\": %2.").arg(nativePath, file.errorString())); - return false; - } - - const int blockModulo = file.size() % TarBlockSize; - if (blockModulo != 0) - tarFile.write(QByteArray(TarBlockSize - blockModulo, 0)); - - if (tarFile.error() != QFile::NoError) { - raiseError(tr("Error writing tar file \"%1\": %2.") - .arg(QDir::toNativeSeparators(tarFile.fileName()), tarFile.errorString())); - return false; - } - return true; -} - static bool setFilePath(TarFileHeader &header, const QByteArray &filePath) { if (filePath.length() <= int(sizeof header.fileName)) { @@ -257,13 +324,14 @@ static bool setFilePath(TarFileHeader &header, const QByteArray &filePath) return false; } -bool TarPackageCreationStep::writeHeader(QFile &tarFile, const QFileInfo &fileInfo, - const QString &remoteFilePath) +static bool writeHeader(QFile &tarFile, const QFileInfo &fileInfo, const QString &remoteFilePath, + const QString &cachedPackageFilePath, QString *errorMessage) { TarFileHeader header; std::memset(&header, '\0', sizeof header); if (!setFilePath(header, remoteFilePath.toUtf8())) { - raiseError(tr("Cannot add file \"%1\" to tar-archive: path too long.").arg(remoteFilePath)); + *errorMessage = QCoreApplication::translate("RemoteLinux::TarPackageCreationStep", + "Cannot add file \"%1\" to tar-archive: path too long.").arg(remoteFilePath); return false; } int permissions = (0400 * fileInfo.permission(QFile::ReadOwner)) @@ -308,89 +376,75 @@ bool TarPackageCreationStep::writeHeader(QFile &tarFile, const QFileInfo &fileIn std::memcpy(&header.chksum, checksumString.data(), checksumString.length()); header.chksum[sizeof header.chksum-1] = 0; if (!tarFile.write(reinterpret_cast(&header), sizeof header)) { - raiseError(tr("Error writing tar file \"%1\": %2") - .arg(cachedPackageFilePath().toUserOutput(), tarFile.errorString())); + *errorMessage = QCoreApplication::translate("RemoteLinux::TarPackageCreationStep", + "Error writing tar file \"%1\": %2").arg(cachedPackageFilePath, tarFile.errorString()); return false; } return true; } -void TarPackageCreationStep::deployFinished(bool success) +bool TarPackageCreationStep::appendFile(QFile &tarFile, const QFileInfo &fileInfo, + const QString &remoteFilePath) { - disconnect(BuildManager::instance(), &BuildManager::buildQueueFinished, - this, &TarPackageCreationStep::deployFinished); - - if (!success) - return; - - const Kit *kit = target()->kit(); - - // Store files that have been tar'd and successfully deployed - const auto files = m_files; - for (const DeployableFile &file : files) - m_deployTimes.saveDeploymentTimeStamp(file, kit, QDateTime()); -} - -QString TarPackageCreationStep::packageFileName() const -{ - return project()->displayName() + QLatin1String(".tar"); -} - -bool TarPackageCreationStep::runImpl() -{ - setPackagingStarted(); - - const QList &files = target()->deploymentData().allFiles(); - - if (m_incrementalDeploymentAspect->value()) { - m_files.clear(); - for (const DeployableFile &file : files) - addNeededDeploymentFiles(file, kit()); - } else { - m_files = files; + QString errorMessage; + if (!writeHeader(tarFile, fileInfo, remoteFilePath, d->m_cachedPackageFilePath.toUserOutput(), + &errorMessage)) { + raiseError(errorMessage); + return false; + } + if (fileInfo.isDir()) { + QDir dir(fileInfo.absoluteFilePath()); + foreach (const QString &fileName, + dir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot)) { + const QString thisLocalFilePath = dir.path() + QLatin1Char('/') + fileName; + const QString thisRemoteFilePath = remoteFilePath + QLatin1Char('/') + fileName; + if (!appendFile(tarFile, QFileInfo(thisLocalFilePath), thisRemoteFilePath)) + return false; + } + return true; } - const bool success = doPackage(); + const QString nativePath = QDir::toNativeSeparators(fileInfo.filePath()); + QFile file(fileInfo.filePath()); + if (!file.open(QIODevice::ReadOnly)) { + const QString message = tr("Error reading file \"%1\": %2.") + .arg(nativePath, file.errorString()); + if (d->m_ignoreMissingFilesAspect->value()) { + raiseWarning(message); + return true; + } else { + raiseError(message); + return false; + } + } - setPackagingFinished(success); - if (success) - emit addOutput(tr("Packaging finished successfully."), OutputFormat::NormalMessage); - else - emit addOutput(tr("Packaging failed."), OutputFormat::ErrorMessage); + const int chunkSize = 1024*1024; - connect(BuildManager::instance(), &BuildManager::buildQueueFinished, - this, &TarPackageCreationStep::deployFinished); + emit addOutput(tr("Adding file \"%1\" to tarball...").arg(nativePath), + OutputFormat::NormalMessage); - return success; -} - -bool TarPackageCreationStep::fromMap(const QVariantMap &map) -{ - if (!AbstractPackagingStep::fromMap(map)) + // TODO: Wasteful. Work with fixed-size buffer. + while (!file.atEnd() && file.error() == QFile::NoError && tarFile.error() == QFile::NoError) { + const QByteArray data = file.read(chunkSize); + tarFile.write(data); + if (isCanceled()) + return false; + } + if (file.error() != QFile::NoError) { + raiseError(tr("Error reading file \"%1\": %2.").arg(nativePath, file.errorString())); return false; - m_deployTimes.importDeployTimes(map); + } + + const int blockModulo = file.size() % TarBlockSize; + if (blockModulo != 0) + tarFile.write(QByteArray(TarBlockSize - blockModulo, 0)); + + if (tarFile.error() != QFile::NoError) { + raiseError(tr("Error writing tar file \"%1\": %2.") + .arg(QDir::toNativeSeparators(tarFile.fileName()), tarFile.errorString())); + return false; + } return true; } -QVariantMap TarPackageCreationStep::toMap() const -{ - QVariantMap map = AbstractPackagingStep::toMap(); -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - map.insert(m_deployTimes.exportDeployTimes()); -#else - map.unite(m_deployTimes.exportDeployTimes()); -#endif - return map; -} - -Utils::Id TarPackageCreationStep::stepId() -{ - return Constants::TarPackageCreationStepId; -} - -QString TarPackageCreationStep::displayName() -{ - return tr("Create tarball"); -} - } // namespace RemoteLinux diff --git a/src/plugins/remotelinux/tarpackagecreationstep.h b/src/plugins/remotelinux/tarpackagecreationstep.h index 3c60815e5f3..73b80fcac2e 100644 --- a/src/plugins/remotelinux/tarpackagecreationstep.h +++ b/src/plugins/remotelinux/tarpackagecreationstep.h @@ -27,60 +27,49 @@ #include "remotelinux_export.h" -#include "abstractpackagingstep.h" -#include "deploymenttimeinfo.h" - -#include +#include QT_BEGIN_NAMESPACE class QFile; class QFileInfo; QT_END_NAMESPACE +namespace ProjectExplorer { class DeployableFile; } + namespace RemoteLinux { -class REMOTELINUX_EXPORT TarPackageCreationStep : public AbstractPackagingStep +namespace Internal { class TarPackageCreationStepPrivate; } + +class REMOTELINUX_EXPORT TarPackageCreationStep : public ProjectExplorer::BuildStep { Q_OBJECT + public: - TarPackageCreationStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id); + explicit TarPackageCreationStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id); + ~TarPackageCreationStep() override; static Utils::Id stepId(); static QString displayName(); - void setIgnoreMissingFiles(bool ignoreMissingFiles); - bool ignoreMissingFiles() const; - - void setIncrementalDeployment(bool incrementalDeployment); - bool isIncrementalDeployment() const; + Utils::FilePath packageFilePath() const; private: bool init() override; void doRun() override; - - void deployFinished(bool success); - - void addNeededDeploymentFiles(const ProjectExplorer::DeployableFile &deployable, - const ProjectExplorer::Kit *kit); - bool fromMap(const QVariantMap &map) override; QVariantMap toMap() const override; - QString packageFileName() const override; - + void raiseError(const QString &errorMessage); + void raiseWarning(const QString &warningMessage); + bool isPackagingNeeded() const; + void deployFinished(bool success); + void addNeededDeploymentFiles(const ProjectExplorer::DeployableFile &deployable, + const ProjectExplorer::Kit *kit); bool runImpl(); bool doPackage(); - bool appendFile(QFile &tarFile, const QFileInfo &fileInfo, - const QString &remoteFilePath); - bool writeHeader(QFile &tarFile, const QFileInfo &fileInfo, - const QString &remoteFilePath); + bool appendFile(QFile &tarFile, const QFileInfo &fileInfo, const QString &remoteFilePath); - DeploymentTimeInfo m_deployTimes; - - Utils::BoolAspect *m_incrementalDeploymentAspect = nullptr; - Utils::BoolAspect *m_ignoreMissingFilesAspect = nullptr; - bool m_packagingNeeded = false; - QList m_files; + std::unique_ptr d; }; } // namespace RemoteLinux From 92b3a513581d235e460a2f911777df860342cf64 Mon Sep 17 00:00:00 2001 From: Artem Sokolovskii Date: Tue, 31 May 2022 16:42:57 +0200 Subject: [PATCH 12/12] QMLPlugins: Remove foreach / Q_FOREACH usage Task-number: QTCREATORBUG-27464 Change-Id: Ie3e3ec9fdaea856943e5325cabd21e52bf290e70 Reviewed-by: Reviewed-by: Ulf Hermann --- src/plugins/qmljstools/qmljsindenter.cpp | 2 +- src/plugins/qmljstools/qmljslocatordata.cpp | 2 +- src/plugins/qmljstools/qmljsmodelmanager.cpp | 26 ++++++++++++------- src/plugins/qmljstools/qmljssemanticinfo.cpp | 2 +- src/plugins/qmlprofiler/flamegraphmodel.cpp | 3 ++- src/plugins/qmlprofiler/pixmapcachemodel.cpp | 2 +- .../qmlprofiler/qmlprofilernotesmodel.cpp | 3 ++- .../qmlprofiler/qmlprofilerstatisticsview.cpp | 4 +-- src/plugins/qmlprofiler/qmlprofilertool.cpp | 6 +++-- .../fileformat/qmlprojectfileformat.cpp | 3 ++- src/plugins/qmlprojectmanager/qmlproject.cpp | 3 ++- .../qmlprojectrunconfiguration.cpp | 5 ++-- 12 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/plugins/qmljstools/qmljsindenter.cpp b/src/plugins/qmljstools/qmljsindenter.cpp index ce6f18eca90..e46891cc26f 100644 --- a/src/plugins/qmljstools/qmljsindenter.cpp +++ b/src/plugins/qmljstools/qmljsindenter.cpp @@ -99,7 +99,7 @@ TextEditor::IndentationForBlock Indenter::indentationForBlocks( codeFormatter.updateStateUntil(blocks.last()); TextEditor::IndentationForBlock ret; - foreach (QTextBlock block, blocks) + for (QTextBlock block : blocks) ret.insert(block.blockNumber(), codeFormatter.indentFor(block)); return ret; } diff --git a/src/plugins/qmljstools/qmljslocatordata.cpp b/src/plugins/qmljstools/qmljslocatordata.cpp index 92611a99a64..9f135b0383b 100644 --- a/src/plugins/qmljstools/qmljslocatordata.cpp +++ b/src/plugins/qmljstools/qmljslocatordata.cpp @@ -252,7 +252,7 @@ void LocatorData::onDocumentUpdated(const Document::Ptr &doc) void LocatorData::onAboutToRemoveFiles(const QStringList &files) { QMutexLocker l(&m_mutex); - foreach (const QString &file, files) { + for (const QString &file : files) { m_entries.remove(file); } } diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp index dffea44be27..941494699ef 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.cpp +++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp @@ -92,10 +92,11 @@ static void setupProjectInfoQmlBundles(ModelManagerInterface::ProjectInfo &proje if (projectInfo.project) { QSet currentKits; - foreach (const Target *t, projectInfo.project->targets()) + const QList targets = projectInfo.project->targets(); + for (const Target *t : targets) currentKits.insert(t->kit()); currentKits.remove(activeKit); - foreach (Kit *kit, currentKits) { + for (Kit *kit : qAsConst(currentKits)) { for (IBundleProvider *bp : IBundleProvider::allBundleProviders()) bp->mergeBundlesForKit(kit, projectInfo.extendedBundle, replacements); } @@ -214,22 +215,28 @@ QHash ModelManager::initLanguageForSuffix() const if (ICore::instance()) { MimeType jsSourceTy = Utils::mimeTypeForName(Constants::JS_MIMETYPE); - foreach (const QString &suffix, jsSourceTy.suffixes()) + const QStringList jsSuffixes = jsSourceTy.suffixes(); + for (const QString &suffix : jsSuffixes) res[suffix] = Dialect::JavaScript; MimeType qmlSourceTy = Utils::mimeTypeForName(Constants::QML_MIMETYPE); - foreach (const QString &suffix, qmlSourceTy.suffixes()) + const QStringList qmlSuffixes = qmlSourceTy.suffixes(); + for (const QString &suffix : qmlSuffixes) res[suffix] = Dialect::Qml; MimeType qbsSourceTy = Utils::mimeTypeForName(Constants::QBS_MIMETYPE); - foreach (const QString &suffix, qbsSourceTy.suffixes()) + const QStringList qbsSuffixes = qbsSourceTy.suffixes(); + for (const QString &suffix : qbsSuffixes) res[suffix] = Dialect::QmlQbs; MimeType qmlProjectSourceTy = Utils::mimeTypeForName(Constants::QMLPROJECT_MIMETYPE); - foreach (const QString &suffix, qmlProjectSourceTy.suffixes()) + const QStringList qmlProjSuffixes = qmlProjectSourceTy.suffixes(); + for (const QString &suffix : qmlProjSuffixes) res[suffix] = Dialect::QmlProject; MimeType qmlUiSourceTy = Utils::mimeTypeForName(Constants::QMLUI_MIMETYPE); - foreach (const QString &suffix, qmlUiSourceTy.suffixes()) + const QStringList qmlUiSuffixes = qmlUiSourceTy.suffixes(); + for (const QString &suffix : qmlUiSuffixes) res[suffix] = Dialect::QmlQtQuick2Ui; MimeType jsonSourceTy = Utils::mimeTypeForName(Constants::JSON_MIMETYPE); - foreach (const QString &suffix, jsonSourceTy.suffixes()) + const QStringList jsonSuffixes = jsonSourceTy.suffixes(); + for (const QString &suffix : jsonSuffixes) res[suffix] = Dialect::Json; } return res; @@ -288,7 +295,8 @@ ModelManagerInterface::WorkingCopy ModelManager::workingCopyInternal() const if (!Core::ICore::instance()) return workingCopy; - foreach (IDocument *document, DocumentModel::openedDocuments()) { + const QList documents = DocumentModel::openedDocuments(); + for (IDocument *document : documents) { const QString key = document->filePath().toString(); if (auto textDocument = qobject_cast(document)) { // TODO the language should be a property on the document, not the editor diff --git a/src/plugins/qmljstools/qmljssemanticinfo.cpp b/src/plugins/qmljstools/qmljssemanticinfo.cpp index b136747e7a0..451d264789b 100644 --- a/src/plugins/qmljstools/qmljssemanticinfo.cpp +++ b/src/plugins/qmljstools/qmljssemanticinfo.cpp @@ -191,7 +191,7 @@ QList SemanticInfo::rangePath(int cursorPosition) const { QList path; - foreach (const Range &range, ranges) { + for (const Range &range : qAsConst(ranges)) { if (range.begin.isNull() || range.end.isNull()) continue; else if (cursorPosition >= range.begin.position() && cursorPosition <= range.end.position()) diff --git a/src/plugins/qmlprofiler/flamegraphmodel.cpp b/src/plugins/qmlprofiler/flamegraphmodel.cpp index d03fd21451d..eb280ce49eb 100644 --- a/src/plugins/qmlprofiler/flamegraphmodel.cpp +++ b/src/plugins/qmlprofiler/flamegraphmodel.cpp @@ -200,7 +200,8 @@ QVariant FlameGraphModel::lookup(const FlameGraphData &stats, int role) const if (!m_typeIdsWithNotes.contains(stats.typeIndex)) return ret; Timeline::TimelineNotesModel *notes = m_modelManager->notesModel(); - foreach (const QVariant &item, notes->byTypeId(stats.typeIndex)) { + const QList items = notes->byTypeId(stats.typeIndex); + for (const QVariant &item : items) { if (ret.isEmpty()) ret = notes->text(item.toInt()); else diff --git a/src/plugins/qmlprofiler/pixmapcachemodel.cpp b/src/plugins/qmlprofiler/pixmapcachemodel.cpp index 3efe0a7d202..5006ef31dfa 100644 --- a/src/plugins/qmlprofiler/pixmapcachemodel.cpp +++ b/src/plugins/qmlprofiler/pixmapcachemodel.cpp @@ -432,7 +432,7 @@ QString PixmapCacheModel::fileName(int index) const void PixmapCacheModel::computeMaxCacheSize() { - foreach (const PixmapCacheModel::Item &event, m_data) { + for (const PixmapCacheModel::Item &event : qAsConst(m_data)) { if (event.pixmapEventType == PixmapCacheModel::PixmapCacheCountChanged) { if (event.cacheSize > m_maxCacheSize) m_maxCacheSize = event.cacheSize; diff --git a/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp b/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp index 35ac01a5ae2..2c30b8e708e 100644 --- a/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp +++ b/src/plugins/qmlprofiler/qmlprofilernotesmodel.cpp @@ -41,7 +41,8 @@ int QmlProfilerNotesModel::addQmlNote(int typeId, int collapsedRow, qint64 start int foundTypeId = -1; int timelineModel = -1; int timelineIndex = -1; - foreach (const Timeline::TimelineModel *model, timelineModels()) { + const QList models = timelineModels(); + for (const Timeline::TimelineModel *model : models) { if (model->handlesTypeId(typeId)) { for (int i = model->firstIndex(start); i <= model->lastIndex(start + duration); ++i) { if (i < 0) diff --git a/src/plugins/qmlprofiler/qmlprofilerstatisticsview.cpp b/src/plugins/qmlprofiler/qmlprofilerstatisticsview.cpp index 81d57358756..8b0fe63d8c8 100644 --- a/src/plugins/qmlprofiler/qmlprofilerstatisticsview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerstatisticsview.cpp @@ -137,8 +137,8 @@ void QmlProfilerStatisticsView::contextMenuEvent(QContextMenuEvent *ev) QPoint position = ev->globalPos(); - QList commonActions = QmlProfilerTool::profilerContextMenuActions(); - foreach (QAction *act, commonActions) + const QList commonActions = QmlProfilerTool::profilerContextMenuActions(); + for (QAction *act : commonActions) menu.addAction(act); if (mouseOnTable(position)) { diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 3c4f75c62c5..c198b60fe88 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -503,7 +503,8 @@ void QmlProfilerTool::setButtonsEnabled(bool enable) void QmlProfilerTool::createInitialTextMarks() { QmlProfilerTextMarkModel *model = d->m_profilerModelManager->textMarkModel(); - foreach (IDocument *document, DocumentModel::openedDocuments()) + const QList documents = DocumentModel::openedDocuments(); + for (IDocument *document : documents) model->createMarks(d->m_viewContainer, document->filePath().toString()); } @@ -736,7 +737,8 @@ void QmlProfilerTool::setAvailableFeatures(quint64 features) void QmlProfilerTool::setRecordedFeatures(quint64 features) { - foreach (QAction *action, d->m_displayFeaturesMenu->actions()) + const QList actions = d->m_displayFeaturesMenu->actions(); + for (QAction *action : actions) action->setEnabled(features & (1ULL << action->data().toUInt())); } diff --git a/src/plugins/qmlprojectmanager/fileformat/qmlprojectfileformat.cpp b/src/plugins/qmlprojectmanager/fileformat/qmlprojectfileformat.cpp index f385cc74660..ec84d34d4a7 100644 --- a/src/plugins/qmlprojectmanager/fileformat/qmlprojectfileformat.cpp +++ b/src/plugins/qmlprojectmanager/fileformat/qmlprojectfileformat.cpp @@ -142,7 +142,8 @@ QmlProjectItem *QmlProjectFileFormat::parseProjectFile(const Utils::FilePath &fi if (debug) qDebug() << "importPath:" << importPathsProperty.value << "mainFile:" << mainFileProperty.value; - foreach (const QmlJS::SimpleReaderNode::Ptr &childNode, rootNode->children()) { + const QList childNodes = rootNode->children(); + for (const QmlJS::SimpleReaderNode::Ptr &childNode : childNodes) { if (debug) qDebug() << "reading type:" << childNode->name(); diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index f25c564edee..b76349ba0a2 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -319,7 +319,8 @@ void QmlBuildSystem::refresh(RefreshOptions options) QmlJS::ModelManagerInterface::ProjectInfo projectInfo = modelManager->defaultProjectInfoForProject(project()); - foreach (const QString &searchPath, makeAbsolute(canonicalProjectDir(), customImportPaths())) + const QStringList searchPaths = makeAbsolute(canonicalProjectDir(), customImportPaths()); + for (const QString &searchPath : searchPaths) projectInfo.importPaths.maybeInsert(Utils::FilePath::fromString(searchPath), QmlJS::Dialect::Qml); diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index d9f89d6f499..9d7805f03f4 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -212,8 +212,9 @@ QString QmlProjectRunConfiguration::commandLineArguments() const // arguments from .qmlproject file const QmlBuildSystem *bs = qobject_cast(target()->buildSystem()); - foreach (const QString &importPath, - QmlBuildSystem::makeAbsolute(bs->targetDirectory(), bs->customImportPaths())) { + const QStringList importPaths = QmlBuildSystem::makeAbsolute(bs->targetDirectory(), + bs->customImportPaths()); + for (const QString &importPath : importPaths) { ProcessArgs::addArg(&args, "-I", osType); ProcessArgs::addArg(&args, importPath, osType); }