From bc2c2bbae943e0ecba18675c78522fa3f7b0e6a7 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 12 Jul 2023 14:09:02 +0200 Subject: [PATCH] AndroidPackageInstallationStep: Employ task tree for running Task-number: QTCREATORBUG-29168 Change-Id: I18d1188a18559bb8030a2c966ea3764833ad96f8 Reviewed-by: Alessandro Portale --- .../androidpackageinstallationstep.cpp | 83 ++++++++++--------- 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/src/plugins/android/androidpackageinstallationstep.cpp b/src/plugins/android/androidpackageinstallationstep.cpp index e29bac3476b..bd3ddfb7f0b 100644 --- a/src/plugins/android/androidpackageinstallationstep.cpp +++ b/src/plugins/android/androidpackageinstallationstep.cpp @@ -122,53 +122,56 @@ void AndroidPackageInstallationStep::setupOutputFormatter(OutputFormatter *forma void AndroidPackageInstallationStep::doRun() { - if (AndroidManager::skipInstallationAndPackageSteps(target())) { - reportWarningOrError(Tr::tr("Product type is not an application, not running the " - "Make install step."), - Task::Warning); - emit finished(true); - return; - } + using namespace Tasking; - QString error; - for (const QString &dir : std::as_const(m_androidDirsToClean)) { - FilePath androidDir = FilePath::fromString(dir); - if (!dir.isEmpty() && androidDir.exists()) { - emit addOutput(Tr::tr("Removing directory %1").arg(dir), OutputFormat::NormalMessage); - if (!androidDir.removeRecursively(&error)) { - reportWarningOrError(Tr::tr("Failed to clean \"%1\" from the previous build, with " - "error:\n%2").arg(androidDir.toUserOutput()).arg(error), - Task::TaskType::Error); - emit finished(false); - return; + const auto onSetup = [this] { + if (AndroidManager::skipInstallationAndPackageSteps(target())) { + reportWarningOrError(Tr::tr("Product type is not an application, not running the " + "Make install step."), Task::Warning); + return SetupResult::StopWithDone; + } + + for (const QString &dir : std::as_const(m_androidDirsToClean)) { + const FilePath androidDir = FilePath::fromString(dir); + if (!dir.isEmpty() && androidDir.exists()) { + emit addOutput(Tr::tr("Removing directory %1").arg(dir), OutputFormat::NormalMessage); + QString error; + if (!androidDir.removeRecursively(&error)) { + reportWarningOrError(Tr::tr("Failed to clean \"%1\" from the previous build, " + "with error:\n%2").arg(androidDir.toUserOutput()).arg(error), + Task::TaskType::Error); + return SetupResult::StopWithError; + } } } - } - AbstractProcessStep::doRun(); - // NOTE: This is a workaround for QTCREATORBUG-24155 - // Needed for Qt 5.15.0 and Qt 5.14.x versions - if (buildType() == BuildConfiguration::BuildType::Debug) { - QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(kit()); - if (version && version->qtVersion() >= QVersionNumber(5, 14) - && version->qtVersion() <= QVersionNumber(5, 15, 0)) { - const QString assetsDebugDir = nativeAndroidBuildPath().append( - "/assets/--Added-by-androiddeployqt--/"); - QDir dir; - if (!dir.exists(assetsDebugDir)) - dir.mkpath(assetsDebugDir); + // NOTE: This is a workaround for QTCREATORBUG-24155 + // Needed for Qt 5.15.0 and Qt 5.14.x versions + if (buildType() == BuildConfiguration::BuildType::Debug) { + QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(kit()); + if (version && version->qtVersion() >= QVersionNumber(5, 14) + && version->qtVersion() <= QVersionNumber(5, 15, 0)) { + const QString assetsDebugDir = nativeAndroidBuildPath().append( + "/assets/--Added-by-androiddeployqt--/"); + QDir dir; + if (!dir.exists(assetsDebugDir)) + dir.mkpath(assetsDebugDir); - QFile file(assetsDebugDir + "debugger.command"); - if (file.open(QIODevice::WriteOnly)) { - qCDebug(packageInstallationStepLog, "Successful added %s to the package.", - qPrintable(file.fileName())); - } else { - qCDebug(packageInstallationStepLog, - "Cannot add %s to the package. The QML debugger might not work properly.", - qPrintable(file.fileName())); + QFile file(assetsDebugDir + "debugger.command"); + if (file.open(QIODevice::WriteOnly)) { + qCDebug(packageInstallationStepLog, "Successful added %s to the package.", + qPrintable(file.fileName())); + } else { + qCDebug(packageInstallationStepLog, + "Cannot add %s to the package. The QML debugger might not work properly.", + qPrintable(file.fileName())); + } } } - } + return SetupResult::Continue; + }; + + runTaskTree({onGroupSetup(onSetup), defaultProcessTask()}); } void AndroidPackageInstallationStep::reportWarningOrError(const QString &message,