forked from qt-creator/qt-creator
Android: Use QtConcurrent invocation for async run
Change-Id: I275af7c52197ecdb0c02e2e1039b37bd8c9bb1c1 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -10,9 +10,9 @@
|
|||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/asynctask.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
#include <utils/runextensions.h>
|
|
||||||
|
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
@@ -139,7 +139,7 @@ AndroidAvdManager::~AndroidAvdManager() = default;
|
|||||||
|
|
||||||
QFuture<CreateAvdInfo> AndroidAvdManager::createAvd(CreateAvdInfo info) const
|
QFuture<CreateAvdInfo> AndroidAvdManager::createAvd(CreateAvdInfo info) const
|
||||||
{
|
{
|
||||||
return runAsync(&createAvdCommand, m_config, info);
|
return Utils::asyncRun(&createAvdCommand, m_config, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidAvdManager::removeAvd(const QString &name) const
|
bool AndroidAvdManager::removeAvd(const QString &name) const
|
||||||
@@ -217,7 +217,7 @@ static AndroidDeviceInfoList listVirtualDevices(const AndroidConfig &config)
|
|||||||
|
|
||||||
QFuture<AndroidDeviceInfoList> AndroidAvdManager::avdList() const
|
QFuture<AndroidDeviceInfoList> AndroidAvdManager::avdList() const
|
||||||
{
|
{
|
||||||
return runAsync(listVirtualDevices, m_config);
|
return Utils::asyncRun(listVirtualDevices, m_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AndroidAvdManager::startAvd(const QString &name) const
|
QString AndroidAvdManager::startAvd(const QString &name) const
|
||||||
|
|||||||
@@ -30,10 +30,10 @@
|
|||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/asynctask.h>
|
||||||
#include <utils/layoutbuilder.h>
|
#include <utils/layoutbuilder.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
#include <utils/runextensions.h>
|
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
@@ -401,16 +401,16 @@ void AndroidDeployQtStep::slotAskForUninstall(DeployErrorCode errorCode)
|
|||||||
m_askForUninstall = button == QMessageBox::Yes;
|
m_askForUninstall = button == QMessageBox::Yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidDeployQtStep::runImpl(QFutureInterface<bool> &fi)
|
void AndroidDeployQtStep::runImpl(QPromise<bool> &promise)
|
||||||
{
|
{
|
||||||
if (!m_avdName.isEmpty()) {
|
if (!m_avdName.isEmpty()) {
|
||||||
const QString serialNumber = AndroidAvdManager().waitForAvd(m_avdName,
|
const QString serialNumber = AndroidAvdManager().waitForAvd(m_avdName,
|
||||||
QFuture<void>(fi.future()));
|
QFuture<void>(promise.future()));
|
||||||
qCDebug(deployStepLog) << "Deploying to AVD:" << m_avdName << serialNumber;
|
qCDebug(deployStepLog) << "Deploying to AVD:" << m_avdName << serialNumber;
|
||||||
if (serialNumber.isEmpty()) {
|
if (serialNumber.isEmpty()) {
|
||||||
reportWarningOrError(Tr::tr("The deployment AVD \"%1\" cannot be started.")
|
reportWarningOrError(Tr::tr("The deployment AVD \"%1\" cannot be started.")
|
||||||
.arg(m_avdName), Task::Error);
|
.arg(m_avdName), Task::Error);
|
||||||
fi.reportResult(false);
|
promise.addResult(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_serialNumber = serialNumber;
|
m_serialNumber = serialNumber;
|
||||||
@@ -446,7 +446,7 @@ void AndroidDeployQtStep::runImpl(QFutureInterface<bool> &fi)
|
|||||||
reportWarningOrError(error, Task::Error);
|
reportWarningOrError(error, Task::Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fi.reportResult(returnValue == NoError);
|
promise.addResult(returnValue == NoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidDeployQtStep::gatherFilesToPull()
|
void AndroidDeployQtStep::gatherFilesToPull()
|
||||||
@@ -486,7 +486,7 @@ void AndroidDeployQtStep::doRun()
|
|||||||
emit finished(success);
|
emit finished(success);
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
});
|
});
|
||||||
auto future = Utils::runAsync(&AndroidDeployQtStep::runImpl, this);
|
auto future = Utils::asyncRun(&AndroidDeployQtStep::runImpl, this);
|
||||||
watcher->setFuture(future);
|
watcher->setFuture(future);
|
||||||
m_synchronizer.addFuture(future);
|
m_synchronizer.addFuture(future);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ private:
|
|||||||
DeployErrorCode runDeploy();
|
DeployErrorCode runDeploy();
|
||||||
void slotAskForUninstall(DeployErrorCode errorCode);
|
void slotAskForUninstall(DeployErrorCode errorCode);
|
||||||
|
|
||||||
void runImpl(QFutureInterface<bool> &fi);
|
void runImpl(QPromise<bool> &promise);
|
||||||
|
|
||||||
QWidget *createConfigWidget() override;
|
QWidget *createConfigWidget() override;
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,9 @@
|
|||||||
#include <projectexplorer/projectmanager.h>
|
#include <projectexplorer/projectmanager.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
|
#include <utils/asynctask.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
#include <utils/runextensions.h>
|
|
||||||
#include <utils/url.h>
|
#include <utils/url.h>
|
||||||
|
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
@@ -454,7 +454,7 @@ void AndroidDeviceManager::startAvd(const ProjectExplorer::IDevice::Ptr &device,
|
|||||||
const AndroidDevice *androidDev = static_cast<const AndroidDevice *>(device.data());
|
const AndroidDevice *androidDev = static_cast<const AndroidDevice *>(device.data());
|
||||||
const QString name = androidDev->avdName();
|
const QString name = androidDev->avdName();
|
||||||
qCDebug(androidDeviceLog, "Starting Android AVD id \"%s\".", qPrintable(name));
|
qCDebug(androidDeviceLog, "Starting Android AVD id \"%s\".", qPrintable(name));
|
||||||
runAsync([this, name, device] {
|
auto future = Utils::asyncRun([this, name, device] {
|
||||||
const QString serialNumber = m_avdManager.startAvd(name);
|
const QString serialNumber = m_avdManager.startAvd(name);
|
||||||
// Mark the AVD as ReadyToUse once we know it's started
|
// Mark the AVD as ReadyToUse once we know it's started
|
||||||
if (!serialNumber.isEmpty()) {
|
if (!serialNumber.isEmpty()) {
|
||||||
@@ -462,6 +462,7 @@ void AndroidDeviceManager::startAvd(const ProjectExplorer::IDevice::Ptr &device,
|
|||||||
devMgr->setDeviceState(device->id(), IDevice::DeviceReadyToUse);
|
devMgr->setDeviceState(device->id(), IDevice::DeviceReadyToUse);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// TODO: use future!
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidDeviceManager::eraseAvd(const IDevice::Ptr &device, QWidget *parent)
|
void AndroidDeviceManager::eraseAvd(const IDevice::Ptr &device, QWidget *parent)
|
||||||
@@ -479,7 +480,7 @@ void AndroidDeviceManager::eraseAvd(const IDevice::Ptr &device, QWidget *parent)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
qCDebug(androidDeviceLog) << QString("Erasing Android AVD \"%1\" from the system.").arg(name);
|
qCDebug(androidDeviceLog) << QString("Erasing Android AVD \"%1\" from the system.").arg(name);
|
||||||
m_removeAvdFutureWatcher.setFuture(runAsync([this, name, device] {
|
m_removeAvdFutureWatcher.setFuture(Utils::asyncRun([this, name, device] {
|
||||||
QPair<IDevice::ConstPtr, bool> pair;
|
QPair<IDevice::ConstPtr, bool> pair;
|
||||||
pair.first = device;
|
pair.first = device;
|
||||||
pair.second = false;
|
pair.second = false;
|
||||||
|
|||||||
@@ -27,8 +27,8 @@
|
|||||||
#include <qtsupport/baseqtversion.h>
|
#include <qtsupport/baseqtversion.h>
|
||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
|
|
||||||
|
#include <utils/asynctask.h>
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
#include <utils/runextensions.h>
|
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDeadlineTimer>
|
#include <QDeadlineTimer>
|
||||||
@@ -163,7 +163,7 @@ bool AndroidQmlPreviewWorker::isPreviewRunning(int lastKnownPid) const
|
|||||||
|
|
||||||
void AndroidQmlPreviewWorker::startPidWatcher()
|
void AndroidQmlPreviewWorker::startPidWatcher()
|
||||||
{
|
{
|
||||||
m_pidFutureWatcher.setFuture(runAsync([this] {
|
m_pidFutureWatcher.setFuture(Utils::asyncRun([this] {
|
||||||
// wait for started
|
// wait for started
|
||||||
const int sleepTimeMs = 2000;
|
const int sleepTimeMs = 2000;
|
||||||
QDeadlineTimer deadline(20000);
|
QDeadlineTimer deadline(20000);
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
#include <debugger/debuggerrunconfigurationaspect.h>
|
#include <debugger/debuggerrunconfigurationaspect.h>
|
||||||
|
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
|
||||||
#include <projectexplorer/environmentaspect.h>
|
#include <projectexplorer/environmentaspect.h>
|
||||||
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/runconfigurationaspects.h>
|
#include <projectexplorer/runconfigurationaspects.h>
|
||||||
#include <projectexplorer/runcontrol.h>
|
#include <projectexplorer/runcontrol.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <qtsupport/baseqtversion.h>
|
#include <qtsupport/baseqtversion.h>
|
||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
|
|
||||||
|
#include <utils/asynctask.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
@@ -77,7 +78,7 @@ static qint64 extractPID(const QString &output, const QString &packageName)
|
|||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void findProcessPID(QFutureInterface<qint64> &fi, QStringList selector,
|
static void findProcessPID(QPromise<qint64> &promise, QStringList selector,
|
||||||
const QString &packageName, bool preNougat)
|
const QString &packageName, bool preNougat)
|
||||||
{
|
{
|
||||||
if (packageName.isEmpty())
|
if (packageName.isEmpty())
|
||||||
@@ -105,11 +106,11 @@ static void findProcessPID(QFutureInterface<qint64> &fi, QStringList selector,
|
|||||||
if (!out.isEmpty())
|
if (!out.isEmpty())
|
||||||
processPID = out.trimmed().toLongLong();
|
processPID = out.trimmed().toLongLong();
|
||||||
}
|
}
|
||||||
} while ((processPID == -1 || processPID == 0) && !isTimedOut(start) && !fi.isCanceled());
|
} while ((processPID == -1 || processPID == 0) && !isTimedOut(start) && !promise.isCanceled());
|
||||||
|
|
||||||
qCDebug(androidRunWorkerLog) << "PID found:" << processPID << ", PreNougat:" << preNougat;
|
qCDebug(androidRunWorkerLog) << "PID found:" << processPID << ", PreNougat:" << preNougat;
|
||||||
if (!fi.isCanceled())
|
if (!promise.isCanceled())
|
||||||
fi.reportResult(processPID);
|
promise.addResult(processPID);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deleter(QProcess *p)
|
static void deleter(QProcess *p)
|
||||||
@@ -683,7 +684,7 @@ void AndroidRunnerWorker::asyncStart()
|
|||||||
{
|
{
|
||||||
asyncStartHelper();
|
asyncStartHelper();
|
||||||
|
|
||||||
m_pidFinder = Utils::onResultReady(Utils::runAsync(findProcessPID, selector(),
|
m_pidFinder = Utils::onResultReady(Utils::asyncRun(findProcessPID, selector(),
|
||||||
m_packageName, m_isPreNougat),
|
m_packageName, m_isPreNougat),
|
||||||
bind(&AndroidRunnerWorker::onProcessIdChanged, this, _1));
|
bind(&AndroidRunnerWorker::onProcessIdChanged, this, _1));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,9 @@
|
|||||||
#include "sdkmanageroutputparser.h"
|
#include "sdkmanageroutputparser.h"
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/asynctask.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
#include <utils/runextensions.h>
|
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
|
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
@@ -34,7 +34,7 @@ namespace Internal {
|
|||||||
const int sdkManagerCmdTimeoutS = 60;
|
const int sdkManagerCmdTimeoutS = 60;
|
||||||
const int sdkManagerOperationTimeoutS = 600;
|
const int sdkManagerOperationTimeoutS = 600;
|
||||||
|
|
||||||
using SdkCmdFutureInterface = QFutureInterface<AndroidSdkManager::OperationOutput>;
|
using SdkCmdPromise = QPromise<AndroidSdkManager::OperationOutput>;
|
||||||
|
|
||||||
static const QRegularExpression &assertionRegExp()
|
static const QRegularExpression &assertionRegExp()
|
||||||
{
|
{
|
||||||
@@ -111,7 +111,7 @@ static bool sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
|
|||||||
after the lapse of \a timeout seconds. The function blocks the calling thread.
|
after the lapse of \a timeout seconds. The function blocks the calling thread.
|
||||||
*/
|
*/
|
||||||
static void sdkManagerCommand(const AndroidConfig &config, const QStringList &args,
|
static void sdkManagerCommand(const AndroidConfig &config, const QStringList &args,
|
||||||
AndroidSdkManager &sdkManager, SdkCmdFutureInterface &fi,
|
AndroidSdkManager &sdkManager, SdkCmdPromise &promise,
|
||||||
AndroidSdkManager::OperationOutput &output, double progressQuota,
|
AndroidSdkManager::OperationOutput &output, double progressQuota,
|
||||||
bool interruptible = true, int timeout = sdkManagerOperationTimeoutS)
|
bool interruptible = true, int timeout = sdkManagerOperationTimeoutS)
|
||||||
{
|
{
|
||||||
@@ -120,19 +120,19 @@ static void sdkManagerCommand(const AndroidConfig &config, const QStringList &ar
|
|||||||
qCDebug(sdkManagerLog).noquote() << "Running SDK Manager command (async):"
|
qCDebug(sdkManagerLog).noquote() << "Running SDK Manager command (async):"
|
||||||
<< CommandLine(config.sdkManagerToolPath(), newArgs)
|
<< CommandLine(config.sdkManagerToolPath(), newArgs)
|
||||||
.toUserOutput();
|
.toUserOutput();
|
||||||
int offset = fi.progressValue();
|
int offset = promise.future().progressValue();
|
||||||
QtcProcess proc;
|
QtcProcess proc;
|
||||||
proc.setEnvironment(AndroidConfigurations::toolsEnvironment(config));
|
proc.setEnvironment(AndroidConfigurations::toolsEnvironment(config));
|
||||||
bool assertionFound = false;
|
bool assertionFound = false;
|
||||||
proc.setTimeoutS(timeout);
|
proc.setTimeoutS(timeout);
|
||||||
proc.setStdOutCallback([offset, progressQuota, &proc, &assertionFound, &fi](const QString &out) {
|
proc.setStdOutCallback([offset, progressQuota, &proc, &assertionFound, &promise](const QString &out) {
|
||||||
int progressPercent = parseProgress(out, assertionFound);
|
int progressPercent = parseProgress(out, assertionFound);
|
||||||
if (assertionFound) {
|
if (assertionFound) {
|
||||||
proc.stop();
|
proc.stop();
|
||||||
proc.waitForFinished();
|
proc.waitForFinished();
|
||||||
}
|
}
|
||||||
if (progressPercent != -1)
|
if (progressPercent != -1)
|
||||||
fi.setProgressValue(offset + qRound((progressPercent / 100.0) * progressQuota));
|
promise.setProgressValue(offset + qRound((progressPercent / 100.0) * progressQuota));
|
||||||
});
|
});
|
||||||
proc.setStdErrCallback([&output](const QString &err) {
|
proc.setStdErrCallback([&output](const QString &err) {
|
||||||
output.stdError = err;
|
output.stdError = err;
|
||||||
@@ -168,12 +168,12 @@ public:
|
|||||||
const AndroidSdkPackageList &allPackages(bool forceUpdate = false);
|
const AndroidSdkPackageList &allPackages(bool forceUpdate = false);
|
||||||
void refreshSdkPackages(bool forceReload = false);
|
void refreshSdkPackages(bool forceReload = false);
|
||||||
|
|
||||||
void parseCommonArguments(QFutureInterface<QString> &fi);
|
void parseCommonArguments(QPromise<QString> &promise);
|
||||||
void updateInstalled(SdkCmdFutureInterface &fi);
|
void updateInstalled(SdkCmdPromise &fi);
|
||||||
void update(SdkCmdFutureInterface &fi, const QStringList &install,
|
void update(SdkCmdPromise &fi, const QStringList &install,
|
||||||
const QStringList &uninstall);
|
const QStringList &uninstall);
|
||||||
void checkPendingLicense(SdkCmdFutureInterface &fi);
|
void checkPendingLicense(SdkCmdPromise &fi);
|
||||||
void getPendingLicense(SdkCmdFutureInterface &fi);
|
void getPendingLicense(SdkCmdPromise &fi);
|
||||||
|
|
||||||
void addWatcher(const QFuture<AndroidSdkManager::OperationOutput> &future);
|
void addWatcher(const QFuture<AndroidSdkManager::OperationOutput> &future);
|
||||||
void setLicenseInput(bool acceptLicense);
|
void setLicenseInput(bool acceptLicense);
|
||||||
@@ -186,7 +186,7 @@ private:
|
|||||||
void reloadSdkPackages();
|
void reloadSdkPackages();
|
||||||
void clearPackages();
|
void clearPackages();
|
||||||
bool onLicenseStdOut(const QString &output, bool notify,
|
bool onLicenseStdOut(const QString &output, bool notify,
|
||||||
AndroidSdkManager::OperationOutput &result, SdkCmdFutureInterface &fi);
|
AndroidSdkManager::OperationOutput &result, SdkCmdPromise &fi);
|
||||||
|
|
||||||
AndroidSdkManager &m_sdkManager;
|
AndroidSdkManager &m_sdkManager;
|
||||||
const AndroidConfig &m_config;
|
const AndroidConfig &m_config;
|
||||||
@@ -308,7 +308,7 @@ bool AndroidSdkManager::packageListingSuccessful() const
|
|||||||
|
|
||||||
QFuture<QString> AndroidSdkManager::availableArguments() const
|
QFuture<QString> AndroidSdkManager::availableArguments() const
|
||||||
{
|
{
|
||||||
return Utils::runAsync(&AndroidSdkManagerPrivate::parseCommonArguments, m_d.get());
|
return Utils::asyncRun(&AndroidSdkManagerPrivate::parseCommonArguments, m_d.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
QFuture<AndroidSdkManager::OperationOutput> AndroidSdkManager::updateAll()
|
QFuture<AndroidSdkManager::OperationOutput> AndroidSdkManager::updateAll()
|
||||||
@@ -316,7 +316,7 @@ QFuture<AndroidSdkManager::OperationOutput> AndroidSdkManager::updateAll()
|
|||||||
if (isBusy()) {
|
if (isBusy()) {
|
||||||
return QFuture<AndroidSdkManager::OperationOutput>();
|
return QFuture<AndroidSdkManager::OperationOutput>();
|
||||||
}
|
}
|
||||||
auto future = Utils::runAsync(&AndroidSdkManagerPrivate::updateInstalled, m_d.get());
|
auto future = Utils::asyncRun(&AndroidSdkManagerPrivate::updateInstalled, m_d.get());
|
||||||
m_d->addWatcher(future);
|
m_d->addWatcher(future);
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
@@ -326,7 +326,7 @@ AndroidSdkManager::update(const QStringList &install, const QStringList &uninsta
|
|||||||
{
|
{
|
||||||
if (isBusy())
|
if (isBusy())
|
||||||
return QFuture<AndroidSdkManager::OperationOutput>();
|
return QFuture<AndroidSdkManager::OperationOutput>();
|
||||||
auto future = Utils::runAsync(&AndroidSdkManagerPrivate::update, m_d.get(), install, uninstall);
|
auto future = Utils::asyncRun(&AndroidSdkManagerPrivate::update, m_d.get(), install, uninstall);
|
||||||
m_d->addWatcher(future);
|
m_d->addWatcher(future);
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
@@ -335,7 +335,7 @@ QFuture<AndroidSdkManager::OperationOutput> AndroidSdkManager::checkPendingLicen
|
|||||||
{
|
{
|
||||||
if (isBusy())
|
if (isBusy())
|
||||||
return QFuture<AndroidSdkManager::OperationOutput>();
|
return QFuture<AndroidSdkManager::OperationOutput>();
|
||||||
auto future = Utils::runAsync(&AndroidSdkManagerPrivate::checkPendingLicense, m_d.get());
|
auto future = Utils::asyncRun(&AndroidSdkManagerPrivate::checkPendingLicense, m_d.get());
|
||||||
m_d->addWatcher(future);
|
m_d->addWatcher(future);
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
@@ -344,7 +344,7 @@ QFuture<AndroidSdkManager::OperationOutput> AndroidSdkManager::runLicenseCommand
|
|||||||
{
|
{
|
||||||
if (isBusy())
|
if (isBusy())
|
||||||
return QFuture<AndroidSdkManager::OperationOutput>();
|
return QFuture<AndroidSdkManager::OperationOutput>();
|
||||||
auto future = Utils::runAsync(&AndroidSdkManagerPrivate::getPendingLicense, m_d.get());
|
auto future = Utils::asyncRun(&AndroidSdkManagerPrivate::getPendingLicense, m_d.get());
|
||||||
m_d->addWatcher(future);
|
m_d->addWatcher(future);
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
@@ -422,29 +422,29 @@ void AndroidSdkManagerPrivate::refreshSdkPackages(bool forceReload)
|
|||||||
reloadSdkPackages();
|
reloadSdkPackages();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidSdkManagerPrivate::updateInstalled(SdkCmdFutureInterface &fi)
|
void AndroidSdkManagerPrivate::updateInstalled(SdkCmdPromise &promise)
|
||||||
{
|
{
|
||||||
fi.setProgressRange(0, 100);
|
promise.setProgressRange(0, 100);
|
||||||
fi.setProgressValue(0);
|
promise.setProgressValue(0);
|
||||||
AndroidSdkManager::OperationOutput result;
|
AndroidSdkManager::OperationOutput result;
|
||||||
result.type = AndroidSdkManager::UpdateAll;
|
result.type = AndroidSdkManager::UpdateAll;
|
||||||
result.stdOutput = Tr::tr("Updating installed packages.");
|
result.stdOutput = Tr::tr("Updating installed packages.");
|
||||||
fi.reportResult(result);
|
promise.addResult(result);
|
||||||
QStringList args("--update");
|
QStringList args("--update");
|
||||||
args << m_config.sdkManagerToolArgs();
|
args << m_config.sdkManagerToolArgs();
|
||||||
if (!fi.isCanceled())
|
if (!promise.isCanceled())
|
||||||
sdkManagerCommand(m_config, args, m_sdkManager, fi, result, 100);
|
sdkManagerCommand(m_config, args, m_sdkManager, promise, result, 100);
|
||||||
else
|
else
|
||||||
qCDebug(sdkManagerLog) << "Update: Operation cancelled before start";
|
qCDebug(sdkManagerLog) << "Update: Operation cancelled before start";
|
||||||
|
|
||||||
if (result.stdError.isEmpty() && !result.success)
|
if (result.stdError.isEmpty() && !result.success)
|
||||||
result.stdError = Tr::tr("Failed.");
|
result.stdError = Tr::tr("Failed.");
|
||||||
result.stdOutput = Tr::tr("Done\n\n");
|
result.stdOutput = Tr::tr("Done\n\n");
|
||||||
fi.reportResult(result);
|
promise.addResult(result);
|
||||||
fi.setProgressValue(100);
|
promise.setProgressValue(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidSdkManagerPrivate::update(SdkCmdFutureInterface &fi, const QStringList &install,
|
void AndroidSdkManagerPrivate::update(SdkCmdPromise &fi, const QStringList &install,
|
||||||
const QStringList &uninstall)
|
const QStringList &uninstall)
|
||||||
{
|
{
|
||||||
fi.setProgressRange(0, 100);
|
fi.setProgressRange(0, 100);
|
||||||
@@ -461,7 +461,7 @@ void AndroidSdkManagerPrivate::update(SdkCmdFutureInterface &fi, const QStringLi
|
|||||||
result.type = AndroidSdkManager::UpdatePackage;
|
result.type = AndroidSdkManager::UpdatePackage;
|
||||||
result.stdOutput = QString("%1 %2").arg(isInstall ? installTag : uninstallTag)
|
result.stdOutput = QString("%1 %2").arg(isInstall ? installTag : uninstallTag)
|
||||||
.arg(packagePath);
|
.arg(packagePath);
|
||||||
fi.reportResult(result);
|
fi.addResult(result);
|
||||||
if (fi.isCanceled())
|
if (fi.isCanceled())
|
||||||
qCDebug(sdkManagerLog) << args << "Update: Operation cancelled before start";
|
qCDebug(sdkManagerLog) << args << "Update: Operation cancelled before start";
|
||||||
else
|
else
|
||||||
@@ -471,7 +471,7 @@ void AndroidSdkManagerPrivate::update(SdkCmdFutureInterface &fi, const QStringLi
|
|||||||
if (result.stdError.isEmpty() && !result.success)
|
if (result.stdError.isEmpty() && !result.success)
|
||||||
result.stdError = Tr::tr("AndroidSdkManager", "Failed");
|
result.stdError = Tr::tr("AndroidSdkManager", "Failed");
|
||||||
result.stdOutput = Tr::tr("AndroidSdkManager", "Done\n\n");
|
result.stdOutput = Tr::tr("AndroidSdkManager", "Done\n\n");
|
||||||
fi.reportResult(result);
|
fi.addResult(result);
|
||||||
return fi.isCanceled();
|
return fi.isCanceled();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -495,7 +495,7 @@ void AndroidSdkManagerPrivate::update(SdkCmdFutureInterface &fi, const QStringLi
|
|||||||
fi.setProgressValue(100);
|
fi.setProgressValue(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidSdkManagerPrivate::checkPendingLicense(SdkCmdFutureInterface &fi)
|
void AndroidSdkManagerPrivate::checkPendingLicense(SdkCmdPromise &fi)
|
||||||
{
|
{
|
||||||
fi.setProgressRange(0, 100);
|
fi.setProgressRange(0, 100);
|
||||||
fi.setProgressValue(0);
|
fi.setProgressValue(0);
|
||||||
@@ -509,11 +509,11 @@ void AndroidSdkManagerPrivate::checkPendingLicense(SdkCmdFutureInterface &fi)
|
|||||||
qCDebug(sdkManagerLog) << "Update: Operation cancelled before start";
|
qCDebug(sdkManagerLog) << "Update: Operation cancelled before start";
|
||||||
}
|
}
|
||||||
|
|
||||||
fi.reportResult(result);
|
fi.addResult(result);
|
||||||
fi.setProgressValue(100);
|
fi.setProgressValue(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidSdkManagerPrivate::getPendingLicense(SdkCmdFutureInterface &fi)
|
void AndroidSdkManagerPrivate::getPendingLicense(SdkCmdPromise &fi)
|
||||||
{
|
{
|
||||||
fi.setProgressRange(0, 100);
|
fi.setProgressRange(0, 100);
|
||||||
fi.setProgressValue(0);
|
fi.setProgressValue(0);
|
||||||
@@ -571,7 +571,7 @@ void AndroidSdkManagerPrivate::getPendingLicense(SdkCmdFutureInterface &fi)
|
|||||||
result.success = licenseCommand.exitStatus() == QProcess::NormalExit;
|
result.success = licenseCommand.exitStatus() == QProcess::NormalExit;
|
||||||
if (!result.success)
|
if (!result.success)
|
||||||
result.stdError = Tr::tr("License command failed.\n\n");
|
result.stdError = Tr::tr("License command failed.\n\n");
|
||||||
fi.reportResult(result);
|
fi.addResult(result);
|
||||||
fi.setProgressValue(100);
|
fi.setProgressValue(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -595,14 +595,14 @@ void AndroidSdkManagerPrivate::clearUserInput()
|
|||||||
|
|
||||||
bool AndroidSdkManagerPrivate::onLicenseStdOut(const QString &output, bool notify,
|
bool AndroidSdkManagerPrivate::onLicenseStdOut(const QString &output, bool notify,
|
||||||
AndroidSdkManager::OperationOutput &result,
|
AndroidSdkManager::OperationOutput &result,
|
||||||
SdkCmdFutureInterface &fi)
|
SdkCmdPromise &fi)
|
||||||
{
|
{
|
||||||
m_licenseTextCache.append(output);
|
m_licenseTextCache.append(output);
|
||||||
const QRegularExpressionMatch assertionMatch = assertionRegExp().match(m_licenseTextCache);
|
const QRegularExpressionMatch assertionMatch = assertionRegExp().match(m_licenseTextCache);
|
||||||
if (assertionMatch.hasMatch()) {
|
if (assertionMatch.hasMatch()) {
|
||||||
if (notify) {
|
if (notify) {
|
||||||
result.stdOutput = m_licenseTextCache;
|
result.stdOutput = m_licenseTextCache;
|
||||||
fi.reportResult(result);
|
fi.addResult(result);
|
||||||
}
|
}
|
||||||
// Clear the current contents. The found license text is dispatched. Continue collecting the
|
// Clear the current contents. The found license text is dispatched. Continue collecting the
|
||||||
// next license text.
|
// next license text.
|
||||||
@@ -620,7 +620,7 @@ void AndroidSdkManagerPrivate::addWatcher(const QFuture<AndroidSdkManager::Opera
|
|||||||
m_activeOperation->setFuture(QFuture<void>(future));
|
m_activeOperation->setFuture(QFuture<void>(future));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidSdkManagerPrivate::parseCommonArguments(QFutureInterface<QString> &fi)
|
void AndroidSdkManagerPrivate::parseCommonArguments(QPromise<QString> &promise)
|
||||||
{
|
{
|
||||||
QString argumentDetails;
|
QString argumentDetails;
|
||||||
QString output;
|
QString output;
|
||||||
@@ -628,7 +628,7 @@ void AndroidSdkManagerPrivate::parseCommonArguments(QFutureInterface<QString> &f
|
|||||||
bool foundTag = false;
|
bool foundTag = false;
|
||||||
const auto lines = output.split('\n');
|
const auto lines = output.split('\n');
|
||||||
for (const QString& line : lines) {
|
for (const QString& line : lines) {
|
||||||
if (fi.isCanceled())
|
if (promise.isCanceled())
|
||||||
break;
|
break;
|
||||||
if (foundTag)
|
if (foundTag)
|
||||||
argumentDetails.append(line + "\n");
|
argumentDetails.append(line + "\n");
|
||||||
@@ -636,8 +636,8 @@ void AndroidSdkManagerPrivate::parseCommonArguments(QFutureInterface<QString> &f
|
|||||||
foundTag = true;
|
foundTag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fi.isCanceled())
|
if (!promise.isCanceled())
|
||||||
fi.reportResult(argumentDetails);
|
promise.addResult(argumentDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidSdkManagerPrivate::clearPackages()
|
void AndroidSdkManagerPrivate::clearPackages()
|
||||||
|
|||||||
Reference in New Issue
Block a user