diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2019-01-25 14:26:34 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2019-01-31 16:10:01 +0000 |
commit | 966f4ea6a9d1e46833fc30df878ba6fa8f919988 (patch) | |
tree | 7f37c2adcf4dd6fe002585fb3b3c2815b21c5f26 /src/plugins/ios | |
parent | 536618b012b44b5ced428fc39600931803d5dd44 (diff) |
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/ios')
-rw-r--r-- | src/plugins/ios/iosbuildstep.cpp | 4 | ||||
-rw-r--r-- | src/plugins/ios/iosbuildstep.h | 5 | ||||
-rw-r--r-- | src/plugins/ios/iosdeploystep.cpp | 19 | ||||
-rw-r--r-- | src/plugins/ios/iosdeploystep.h | 11 | ||||
-rw-r--r-- | src/plugins/ios/iosdsymbuildstep.cpp | 4 | ||||
-rw-r--r-- | src/plugins/ios/iosdsymbuildstep.h | 9 |
6 files changed, 21 insertions, 31 deletions
diff --git a/src/plugins/ios/iosbuildstep.cpp b/src/plugins/ios/iosbuildstep.cpp index 7aa3b413be4..8d78446c510 100644 --- a/src/plugins/ios/iosbuildstep.cpp +++ b/src/plugins/ios/iosbuildstep.cpp @@ -169,9 +169,9 @@ QString IosBuildStep::buildCommand() const return QString("xcodebuild"); // add path? } -void IosBuildStep::run(QFutureInterface<bool> &fi) +void IosBuildStep::doRun() { - AbstractProcessStep::run(fi); + AbstractProcessStep::doRun(); } BuildStepConfigWidget *IosBuildStep::createConfigWidget() diff --git a/src/plugins/ios/iosbuildstep.h b/src/plugins/ios/iosbuildstep.h index b2ee50c5780..227f88b17af 100644 --- a/src/plugins/ios/iosbuildstep.h +++ b/src/plugins/ios/iosbuildstep.h @@ -48,9 +48,6 @@ class IosBuildStep : public ProjectExplorer::AbstractProcessStep public: explicit IosBuildStep(ProjectExplorer::BuildStepList *parent); - bool init() override; - void run(QFutureInterface<bool> &fi) override; - ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; void setBaseArguments(const QStringList &args); void setExtraArguments(const QStringList &extraArgs); @@ -60,6 +57,8 @@ public: QString buildCommand() const; private: + bool init() override; + void doRun() override; bool fromMap(const QVariantMap &map) override; QVariantMap toMap() const override; diff --git a/src/plugins/ios/iosdeploystep.cpp b/src/plugins/ios/iosdeploystep.cpp index ff9e376cfe0..65a225e7e6c 100644 --- a/src/plugins/ios/iosdeploystep.cpp +++ b/src/plugins/ios/iosdeploystep.cpp @@ -58,7 +58,6 @@ IosDeployStep::IosDeployStep(BuildStepList *parent) : BuildStep(parent, stepId()) { setImmutable(true); - setRunInGuiThread(true); updateDisplayNames(); connect(DeviceManager::instance(), &DeviceManager::updated, this, &IosDeployStep::updateDisplayNames); @@ -101,22 +100,19 @@ bool IosDeployStep::init() return true; } -void IosDeployStep::run(QFutureInterface<bool> &fi) +void IosDeployStep::doRun() { - m_futureInterface = fi; QTC_CHECK(m_transferStatus == NoTransfer); if (device().isNull()) { TaskHub::addTask(Task::Error, tr("Deployment failed. No iOS device found."), ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT); - reportRunResult(m_futureInterface, !iossimulator().isNull()); + emit finished(!iossimulator().isNull()); cleanup(); return; } m_toolHandler = new IosToolHandler(m_deviceType, this); m_transferStatus = TransferInProgress; - m_futureInterface.setProgressRange(0, 200); - m_futureInterface.setProgressValueAndText(0, QLatin1String("Transferring application")); - m_futureInterface.reportStarted(); + emit progress(0, tr("Transferring application")); connect(m_toolHandler, &IosToolHandler::isTransferringApp, this, &IosDeployStep::handleIsTransferringApp); connect(m_toolHandler, &IosToolHandler::didTransferApp, @@ -129,7 +125,7 @@ void IosDeployStep::run(QFutureInterface<bool> &fi) m_toolHandler->requestTransferApp(appBundle(), m_deviceType.identifier); } -void IosDeployStep::cancel() +void IosDeployStep::doCancel() { if (m_toolHandler) m_toolHandler->stop(); @@ -150,8 +146,7 @@ void IosDeployStep::handleIsTransferringApp(IosToolHandler *handler, const QStri { Q_UNUSED(handler); Q_UNUSED(bundlePath); Q_UNUSED(deviceId); QTC_CHECK(m_transferStatus == TransferInProgress); - m_futureInterface.setProgressRange(0, maxProgress); - m_futureInterface.setProgressValueAndText(progress, info); + emit this->progress(progress * 100 / maxProgress, info); } void IosDeployStep::handleDidTransferApp(IosToolHandler *handler, const QString &bundlePath, @@ -168,7 +163,7 @@ void IosDeployStep::handleDidTransferApp(IosToolHandler *handler, const QString tr("Deployment failed. The settings in the Devices window of Xcode might be incorrect."), ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT); } - reportRunResult(m_futureInterface, status == IosToolHandler::Success); + emit finished(status == IosToolHandler::Success); } void IosDeployStep::handleFinished(IosToolHandler *handler) @@ -178,7 +173,7 @@ void IosDeployStep::handleFinished(IosToolHandler *handler) m_transferStatus = TransferFailed; TaskHub::addTask(Task::Error, tr("Deployment failed."), ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT); - reportRunResult(m_futureInterface, false); + emit finished(false); break; case NoTransfer: case TransferOk: diff --git a/src/plugins/ios/iosdeploystep.h b/src/plugins/ios/iosdeploystep.h index d3be8937124..56ce87fec36 100644 --- a/src/plugins/ios/iosdeploystep.h +++ b/src/plugins/ios/iosdeploystep.h @@ -32,7 +32,6 @@ #include <projectexplorer/buildstep.h> #include <projectexplorer/devicesupport/idevice.h> -#include <QFutureInterface> #include <QProcess> namespace Ios { @@ -54,14 +53,13 @@ public: explicit IosDeployStep(ProjectExplorer::BuildStepList *bc); static Core::Id stepId(); + void cleanup(); +private: + void doRun() override; + void doCancel() override; bool fromMap(const QVariantMap &map) override; QVariantMap toMap() const override; - void run(QFutureInterface<bool> &fi) override; - void cleanup(); - void cancel() override; - -private: void handleIsTransferringApp(Ios::IosToolHandler *handler, const QString &bundlePath, const QString &deviceId, int progress, int maxProgress, const QString &info); @@ -85,7 +83,6 @@ private: TransferStatus m_transferStatus = NoTransfer; IosToolHandler *m_toolHandler = nullptr; - QFutureInterface<bool> m_futureInterface; ProjectExplorer::IDevice::ConstPtr m_device; QString m_bundlePath; IosDeviceType m_deviceType; diff --git a/src/plugins/ios/iosdsymbuildstep.cpp b/src/plugins/ios/iosdsymbuildstep.cpp index 99bf6679409..c8b550352c1 100644 --- a/src/plugins/ios/iosdsymbuildstep.cpp +++ b/src/plugins/ios/iosdsymbuildstep.cpp @@ -187,9 +187,9 @@ bool IosDsymBuildStep::isDefault() const return arguments() == defaultArguments() && command() == defaultCommand(); } -void IosDsymBuildStep::run(QFutureInterface<bool> &fi) +void IosDsymBuildStep::doRun() { - AbstractProcessStep::run(fi); + AbstractProcessStep::doRun(); } BuildStepConfigWidget *IosDsymBuildStep::createConfigWidget() diff --git a/src/plugins/ios/iosdsymbuildstep.h b/src/plugins/ios/iosdsymbuildstep.h index 2900c54464e..1cd8abcb290 100644 --- a/src/plugins/ios/iosdsymbuildstep.h +++ b/src/plugins/ios/iosdsymbuildstep.h @@ -42,9 +42,6 @@ class IosDsymBuildStep : public ProjectExplorer::AbstractProcessStep public: IosDsymBuildStep(ProjectExplorer::BuildStepList *parent); - bool init() override; - void run(QFutureInterface<bool> &fi) override; - ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; void setArguments(const QStringList &args); QStringList arguments() const; @@ -54,10 +51,12 @@ public: void setCommand(const QString &command); bool isDefault() const; - QVariantMap toMap() const override; - private: + bool init() override; + void doRun() override; + QVariantMap toMap() const override; bool fromMap(const QVariantMap &map) override; + QStringList defaultCleanCmdList() const; QStringList defaultCmdList() const; |