aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/android/androiddeployqtstep.cpp
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2022-11-09 16:05:25 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2022-11-25 12:15:18 +0000
commit1e632d0c25bdb0d29361e88bb7dcb22567e2b047 (patch)
tree2aa7f5d69071401e180fd9b1fc86de086cd466b5 /src/plugins/android/androiddeployqtstep.cpp
parent038771051d62824368ae94b73e07c1b5ae62cec4 (diff)
AndroidDeployQtStep: Make it cancelable
And use QFutureInterface for it. Change-Id: I1145b70b119d92af7316977c813f4f29b1f20b74 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/android/androiddeployqtstep.cpp')
-rw-r--r--src/plugins/android/androiddeployqtstep.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/plugins/android/androiddeployqtstep.cpp b/src/plugins/android/androiddeployqtstep.cpp
index f032f84986..e7ee2540a5 100644
--- a/src/plugins/android/androiddeployqtstep.cpp
+++ b/src/plugins/android/androiddeployqtstep.cpp
@@ -3,16 +3,14 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#include "androidavdmanager.h"
+#include "androidbuildapkstep.h"
#include "androidconstants.h"
#include "androiddeployqtstep.h"
#include "androiddevice.h"
-#include "androidglobal.h"
#include "androidmanager.h"
#include "androidqtversion.h"
#include "androidtr.h"
#include "androidtr.h"
-#include "certificatesmodel.h"
-#include "javaparser.h"
#include <coreplugin/fileutils.h>
#include <coreplugin/icore.h>
@@ -35,6 +33,7 @@
#include <utils/layoutbuilder.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
+#include <utils/runextensions.h>
#include <QCheckBox>
#include <QFileDialog>
@@ -402,15 +401,16 @@ void AndroidDeployQtStep::slotAskForUninstall(DeployErrorCode errorCode)
m_askForUninstall = button == QMessageBox::Yes;
}
-bool AndroidDeployQtStep::runImpl()
+void AndroidDeployQtStep::runImpl(QFutureInterface<bool> &fi)
{
if (!m_avdName.isEmpty()) {
- QString serialNumber = AndroidAvdManager().waitForAvd(m_avdName, cancelChecker());
+ QString serialNumber = AndroidAvdManager().waitForAvd(m_avdName, fi);
qCDebug(deployStepLog) << "Deploying to AVD:" << m_avdName << serialNumber;
if (serialNumber.isEmpty()) {
reportWarningOrError(Tr::tr("The deployment AVD \"%1\" cannot be started.")
.arg(m_avdName), Task::Error);
- return false;
+ fi.reportResult(false);
+ return;
}
m_serialNumber = serialNumber;
qCDebug(deployStepLog) << "Deployment device serial number changed:" << serialNumber;
@@ -445,8 +445,7 @@ bool AndroidDeployQtStep::runImpl()
reportWarningOrError(error, Task::Error);
}
}
-
- return returnValue == NoError;
+ fi.reportResult(returnValue == NoError);
}
void AndroidDeployQtStep::gatherFilesToPull()
@@ -480,7 +479,20 @@ void AndroidDeployQtStep::gatherFilesToPull()
void AndroidDeployQtStep::doRun()
{
- m_synchronizer.addFuture(runInThread([this] { return runImpl(); }));
+ auto * const watcher = new QFutureWatcher<bool>(this);
+ connect(watcher, &QFutureWatcher<bool>::finished, this, [this, watcher] {
+ const bool success = !watcher->isCanceled() && watcher->result();
+ emit finished(success);
+ watcher->deleteLater();
+ });
+ auto future = Utils::runAsync(&AndroidDeployQtStep::runImpl, this);
+ watcher->setFuture(future);
+ m_synchronizer.addFuture(future);
+}
+
+void AndroidDeployQtStep::doCancel()
+{
+ m_synchronizer.cancelAllFutures();
}
void AndroidDeployQtStep::runCommand(const CommandLine &command)