forked from qt-creator/qt-creator
RemoteLinux: Move deployservice ownership to AbstractRemoteLinuxDeployStep
Change-Id: I12cfa0d2cdb171d381e6fde6b0e71fc0c098d746 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -41,6 +41,8 @@ class AbstractRemoteLinuxDeployStepPrivate
|
||||
public:
|
||||
bool hasError;
|
||||
std::function<CheckResult()> internalInit;
|
||||
std::function<void()> runPreparer;
|
||||
AbstractRemoteLinuxDeployService *deployService = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
@@ -55,8 +57,19 @@ void AbstractRemoteLinuxDeployStep::setInternalInitializer(const std::function<C
|
||||
d->internalInit = init;
|
||||
}
|
||||
|
||||
void AbstractRemoteLinuxDeployStep::setRunPreparer(const std::function<void ()> &prep)
|
||||
{
|
||||
d->runPreparer = prep;
|
||||
}
|
||||
|
||||
void AbstractRemoteLinuxDeployStep::setDeployService(AbstractRemoteLinuxDeployService *service)
|
||||
{
|
||||
d->deployService = service;
|
||||
}
|
||||
|
||||
AbstractRemoteLinuxDeployStep::~AbstractRemoteLinuxDeployStep()
|
||||
{
|
||||
delete d->deployService;
|
||||
delete d;
|
||||
}
|
||||
|
||||
@@ -64,18 +77,18 @@ bool AbstractRemoteLinuxDeployStep::fromMap(const QVariantMap &map)
|
||||
{
|
||||
if (!BuildStep::fromMap(map))
|
||||
return false;
|
||||
deployService()->importDeployTimes(map);
|
||||
d->deployService->importDeployTimes(map);
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariantMap AbstractRemoteLinuxDeployStep::toMap() const
|
||||
{
|
||||
return BuildStep::toMap().unite(deployService()->exportDeployTimes());
|
||||
return BuildStep::toMap().unite(d->deployService->exportDeployTimes());
|
||||
}
|
||||
|
||||
bool AbstractRemoteLinuxDeployStep::init()
|
||||
{
|
||||
deployService()->setTarget(target());
|
||||
d->deployService->setTarget(target());
|
||||
|
||||
QTC_ASSERT(d->internalInit, return false);
|
||||
const CheckResult canDeploy = d->internalInit();
|
||||
@@ -88,21 +101,24 @@ bool AbstractRemoteLinuxDeployStep::init()
|
||||
|
||||
void AbstractRemoteLinuxDeployStep::doRun()
|
||||
{
|
||||
connect(deployService(), &AbstractRemoteLinuxDeployService::errorMessage,
|
||||
if (d->runPreparer)
|
||||
d->runPreparer();
|
||||
|
||||
connect(d->deployService, &AbstractRemoteLinuxDeployService::errorMessage,
|
||||
this, &AbstractRemoteLinuxDeployStep::handleErrorMessage);
|
||||
connect(deployService(), &AbstractRemoteLinuxDeployService::progressMessage,
|
||||
connect(d->deployService, &AbstractRemoteLinuxDeployService::progressMessage,
|
||||
this, &AbstractRemoteLinuxDeployStep::handleProgressMessage);
|
||||
connect(deployService(), &AbstractRemoteLinuxDeployService::warningMessage,
|
||||
connect(d->deployService, &AbstractRemoteLinuxDeployService::warningMessage,
|
||||
this, &AbstractRemoteLinuxDeployStep::handleWarningMessage);
|
||||
connect(deployService(), &AbstractRemoteLinuxDeployService::stdOutData,
|
||||
connect(d->deployService, &AbstractRemoteLinuxDeployService::stdOutData,
|
||||
this, &AbstractRemoteLinuxDeployStep::handleStdOutData);
|
||||
connect(deployService(), &AbstractRemoteLinuxDeployService::stdErrData,
|
||||
connect(d->deployService, &AbstractRemoteLinuxDeployService::stdErrData,
|
||||
this, &AbstractRemoteLinuxDeployStep::handleStdErrData);
|
||||
connect(deployService(), &AbstractRemoteLinuxDeployService::finished,
|
||||
connect(d->deployService, &AbstractRemoteLinuxDeployService::finished,
|
||||
this, &AbstractRemoteLinuxDeployStep::handleFinished);
|
||||
|
||||
d->hasError = false;
|
||||
deployService()->start();
|
||||
d->deployService->start();
|
||||
}
|
||||
|
||||
void AbstractRemoteLinuxDeployStep::doCancel()
|
||||
@@ -113,7 +129,7 @@ void AbstractRemoteLinuxDeployStep::doCancel()
|
||||
emit addOutput(tr("User requests deployment to stop; cleaning up."),
|
||||
OutputFormat::NormalMessage);
|
||||
d->hasError = true;
|
||||
deployService()->stop();
|
||||
d->deployService->stop();
|
||||
}
|
||||
|
||||
void AbstractRemoteLinuxDeployStep::handleProgressMessage(const QString &message)
|
||||
@@ -144,7 +160,7 @@ void AbstractRemoteLinuxDeployStep::handleFinished()
|
||||
emit addOutput(tr("Deploy step failed."), OutputFormat::ErrorMessage);
|
||||
else
|
||||
emit addOutput(tr("Deploy step finished."), OutputFormat::NormalMessage);
|
||||
disconnect(deployService(), nullptr, this, nullptr);
|
||||
disconnect(d->deployService, nullptr, this, nullptr);
|
||||
emit finished(!d->hasError);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user