forked from qt-creator/qt-creator
AbstractRemoteLinuxDeployService: Simplify internals
Change-Id: Ib24c00405f863788f3b72107891193b566feb3e7 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -23,10 +23,6 @@ using namespace Utils;
|
|||||||
namespace RemoteLinux {
|
namespace RemoteLinux {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
namespace {
|
|
||||||
enum State { Inactive, Deploying, Stopping };
|
|
||||||
} // anonymous namespace
|
|
||||||
|
|
||||||
class AbstractRemoteLinuxDeployServicePrivate
|
class AbstractRemoteLinuxDeployServicePrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -34,9 +30,9 @@ public:
|
|||||||
QPointer<Target> target;
|
QPointer<Target> target;
|
||||||
|
|
||||||
DeploymentTimeInfo deployTimes;
|
DeploymentTimeInfo deployTimes;
|
||||||
State state = Inactive;
|
|
||||||
std::unique_ptr<TaskTree> m_taskTree;
|
std::unique_ptr<TaskTree> m_taskTree;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
using namespace Internal;
|
using namespace Internal;
|
||||||
@@ -97,7 +93,7 @@ void AbstractRemoteLinuxDeployService::setDevice(const IDevice::ConstPtr &device
|
|||||||
|
|
||||||
void AbstractRemoteLinuxDeployService::start()
|
void AbstractRemoteLinuxDeployService::start()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(d->state == Inactive, return);
|
QTC_ASSERT(!d->m_taskTree, return);
|
||||||
|
|
||||||
const CheckResult check = isDeploymentPossible();
|
const CheckResult check = isDeploymentPossible();
|
||||||
if (!check) {
|
if (!check) {
|
||||||
@@ -112,16 +108,22 @@ void AbstractRemoteLinuxDeployService::start()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->state = Deploying;
|
d->m_taskTree.reset(new TaskTree(deployRecipe()));
|
||||||
doDeploy();
|
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()
|
void AbstractRemoteLinuxDeployService::stop()
|
||||||
{
|
{
|
||||||
if (d->state != Deploying)
|
if (!d->m_taskTree)
|
||||||
return;
|
return;
|
||||||
d->state = Stopping;
|
d->m_taskTree.reset();
|
||||||
stopDeployment();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckResult AbstractRemoteLinuxDeployService::isDeploymentPossible() const
|
CheckResult AbstractRemoteLinuxDeployService::isDeploymentPossible() const
|
||||||
@@ -141,30 +143,4 @@ void AbstractRemoteLinuxDeployService::importDeployTimes(const QVariantMap &map)
|
|||||||
d->deployTimes.importDeployTimes(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
|
} // namespace RemoteLinux
|
||||||
|
@@ -75,13 +75,9 @@ protected:
|
|||||||
bool hasRemoteFileChanged(const ProjectExplorer::DeployableFile &deployableFile,
|
bool hasRemoteFileChanged(const ProjectExplorer::DeployableFile &deployableFile,
|
||||||
const QDateTime &remoteTimestamp) const;
|
const QDateTime &remoteTimestamp) const;
|
||||||
|
|
||||||
void handleDeploymentDone();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual bool isDeploymentNecessary() const = 0;
|
virtual bool isDeploymentNecessary() const = 0;
|
||||||
virtual Utils::Tasking::Group deployRecipe() = 0;
|
virtual Utils::Tasking::Group deployRecipe() = 0;
|
||||||
void doDeploy();
|
|
||||||
void stopDeployment();
|
|
||||||
|
|
||||||
Internal::AbstractRemoteLinuxDeployServicePrivate * const d;
|
Internal::AbstractRemoteLinuxDeployServicePrivate * const d;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user