diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2022-11-24 22:20:25 +0100 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2022-11-25 13:35:34 +0000 |
commit | 133099aa81c3d3ba0f7ec8f3490cbb3942b66966 (patch) | |
tree | 6b8e3cd762fbd2cb532e5542e03faabc0ed44e5e | |
parent | 49d6456b66146d5f58a63ff5031d58d9b82d173c (diff) |
AbstractRemoteLinuxDeployService: Simplify internals
Change-Id: Ib24c00405f863788f3b72107891193b566feb3e7
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
-rw-r--r-- | src/plugins/remotelinux/abstractremotelinuxdeployservice.cpp | 50 | ||||
-rw-r--r-- | src/plugins/remotelinux/abstractremotelinuxdeployservice.h | 4 |
2 files changed, 13 insertions, 41 deletions
diff --git a/src/plugins/remotelinux/abstractremotelinuxdeployservice.cpp b/src/plugins/remotelinux/abstractremotelinuxdeployservice.cpp index 5c66d61067..b72d45f934 100644 --- a/src/plugins/remotelinux/abstractremotelinuxdeployservice.cpp +++ b/src/plugins/remotelinux/abstractremotelinuxdeployservice.cpp @@ -23,10 +23,6 @@ using namespace Utils; namespace RemoteLinux { namespace Internal { -namespace { -enum State { Inactive, Deploying, Stopping }; -} // anonymous namespace - class AbstractRemoteLinuxDeployServicePrivate { public: @@ -34,9 +30,9 @@ public: QPointer<Target> target; DeploymentTimeInfo deployTimes; - State state = Inactive; std::unique_ptr<TaskTree> m_taskTree; }; + } // namespace Internal using namespace Internal; @@ -97,7 +93,7 @@ void AbstractRemoteLinuxDeployService::setDevice(const IDevice::ConstPtr &device void AbstractRemoteLinuxDeployService::start() { - QTC_ASSERT(d->state == Inactive, return); + QTC_ASSERT(!d->m_taskTree, return); const CheckResult check = isDeploymentPossible(); if (!check) { @@ -112,16 +108,22 @@ void AbstractRemoteLinuxDeployService::start() return; } - d->state = Deploying; - doDeploy(); + d->m_taskTree.reset(new TaskTree(deployRecipe())); + const auto endHandler = [this] { + d->m_taskTree.release()->deleteLater(); + emit finished(); + }; + connect(d->m_taskTree.get(), &TaskTree::done, this, endHandler); + connect(d->m_taskTree.get(), &TaskTree::errorOccurred, this, endHandler); + d->m_taskTree->start(); } void AbstractRemoteLinuxDeployService::stop() { - if (d->state != Deploying) + if (!d->m_taskTree) return; - d->state = Stopping; - stopDeployment(); + d->m_taskTree.reset(); + emit finished(); } CheckResult AbstractRemoteLinuxDeployService::isDeploymentPossible() const @@ -141,30 +143,4 @@ void AbstractRemoteLinuxDeployService::importDeployTimes(const QVariantMap &map) d->deployTimes.importDeployTimes(map); } -void AbstractRemoteLinuxDeployService::handleDeploymentDone() -{ - QTC_ASSERT(d->state != Inactive, return); - d->state = Inactive; - emit finished(); -} - -void AbstractRemoteLinuxDeployService::doDeploy() -{ - QTC_ASSERT(!d->m_taskTree, return); - d->m_taskTree.reset(new TaskTree(deployRecipe())); - const auto endHandler = [this] { - d->m_taskTree.release()->deleteLater(); - handleDeploymentDone(); - }; - connect(d->m_taskTree.get(), &TaskTree::done, this, endHandler); - connect(d->m_taskTree.get(), &TaskTree::errorOccurred, this, endHandler); - d->m_taskTree->start(); -} - -void AbstractRemoteLinuxDeployService::stopDeployment() -{ - d->m_taskTree.reset(); - handleDeploymentDone(); -} - } // namespace RemoteLinux diff --git a/src/plugins/remotelinux/abstractremotelinuxdeployservice.h b/src/plugins/remotelinux/abstractremotelinuxdeployservice.h index f66691971b..893447d041 100644 --- a/src/plugins/remotelinux/abstractremotelinuxdeployservice.h +++ b/src/plugins/remotelinux/abstractremotelinuxdeployservice.h @@ -75,13 +75,9 @@ protected: bool hasRemoteFileChanged(const ProjectExplorer::DeployableFile &deployableFile, const QDateTime &remoteTimestamp) const; - void handleDeploymentDone(); - private: virtual bool isDeploymentNecessary() const = 0; virtual Utils::Tasking::Group deployRecipe() = 0; - void doDeploy(); - void stopDeployment(); Internal::AbstractRemoteLinuxDeployServicePrivate * const d; }; |