AndroidDeployQtStep: Use promise for checking canceled state

Change-Id: I4fec6004b0b17be182088dab4deb49aa2d7c8a0b
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Jarek Kobus
2023-07-15 09:44:27 +02:00
parent 301e18f12b
commit 134eee611a

View File

@@ -91,7 +91,7 @@ private:
bool init() override; bool init() override;
Tasking::GroupItem runRecipe() final; Tasking::GroupItem runRecipe() final;
void gatherFilesToPull(); void gatherFilesToPull();
DeployErrorCode runDeploy(); DeployErrorCode runDeploy(QPromise<void> &promise);
void slotAskForUninstall(DeployErrorCode errorCode); void slotAskForUninstall(DeployErrorCode errorCode);
void runImpl(QPromise<void> &promise); void runImpl(QPromise<void> &promise);
@@ -341,7 +341,7 @@ bool AndroidDeployQtStep::init()
return true; return true;
} }
AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy() AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy(QPromise<void> &promise)
{ {
CommandLine cmd(m_command); CommandLine cmd(m_command);
if (m_useAndroiddeployqt && m_apkPath.isEmpty()) { if (m_useAndroiddeployqt && m_apkPath.isEmpty()) {
@@ -404,7 +404,7 @@ AndroidDeployQtStep::DeployErrorCode AndroidDeployQtStep::runDeploy()
if (process.state() == QProcess::NotRunning) if (process.state() == QProcess::NotRunning)
break; break;
if (isCanceled()) { if (promise.isCanceled()) {
process.kill(); process.kill();
process.waitForFinished(); process.waitForFinished();
} }
@@ -494,12 +494,12 @@ void AndroidDeployQtStep::runImpl(QPromise<void> &promise)
AndroidManager::setDeviceSerialNumber(target(), serialNumber); AndroidManager::setDeviceSerialNumber(target(), serialNumber);
} }
DeployErrorCode returnValue = runDeploy(); DeployErrorCode returnValue = runDeploy(promise);
if (returnValue > DeployErrorCode::NoError && returnValue < DeployErrorCode::Failure) { if (returnValue > DeployErrorCode::NoError && returnValue < DeployErrorCode::Failure) {
emit askForUninstall(returnValue); emit askForUninstall(returnValue);
if (m_askForUninstall) { if (m_askForUninstall) {
m_uninstallPreviousPackageRun = true; m_uninstallPreviousPackageRun = true;
returnValue = runDeploy(); returnValue = runDeploy(promise);
} }
} }