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/qbsprojectmanager/qbsinstallstep.cpp | |
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/qbsprojectmanager/qbsinstallstep.cpp')
-rw-r--r-- | src/plugins/qbsprojectmanager/qbsinstallstep.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/plugins/qbsprojectmanager/qbsinstallstep.cpp b/src/plugins/qbsprojectmanager/qbsinstallstep.cpp index 75152c6ac1..c375c87cac 100644 --- a/src/plugins/qbsprojectmanager/qbsinstallstep.cpp +++ b/src/plugins/qbsprojectmanager/qbsinstallstep.cpp @@ -61,7 +61,6 @@ QbsInstallStep::QbsInstallStep(ProjectExplorer::BuildStepList *bsl) : ProjectExplorer::BuildStep(bsl, Constants::QBS_INSTALLSTEP_ID) { setDisplayName(tr("Qbs Install")); - setRunInGuiThread(true); const QbsBuildConfiguration * const bc = buildConfig(); connect(bc, &QbsBuildConfiguration::qbsConfigurationChanged, @@ -74,7 +73,7 @@ QbsInstallStep::QbsInstallStep(ProjectExplorer::BuildStepList *bsl) : QbsInstallStep::~QbsInstallStep() { - cancel(); + doCancel(); if (m_job) m_job->deleteLater(); m_job = nullptr; @@ -86,19 +85,17 @@ bool QbsInstallStep::init() return true; } -void QbsInstallStep::run(QFutureInterface<bool> &fi) +void QbsInstallStep::doRun() { - m_fi = &fi; - auto pro = static_cast<QbsProject *>(project()); m_job = pro->install(m_qbsInstallOptions); if (!m_job) { - reportRunResult(*m_fi, false); + emit finished(false); return; } - m_progressBase = 0; + m_maxProgress = 0; connect(m_job, &qbs::AbstractJob::finished, this, &QbsInstallStep::installDone); connect(m_job, &qbs::AbstractJob::taskStarted, @@ -112,7 +109,7 @@ ProjectExplorer::BuildStepConfigWidget *QbsInstallStep::createConfigWidget() return new QbsInstallStepConfigWidget(this); } -void QbsInstallStep::cancel() +void QbsInstallStep::doCancel() { if (m_job) m_job->cancel(); @@ -180,25 +177,21 @@ void QbsInstallStep::installDone(bool success) item.codeLocation().filePath(), item.codeLocation().line()); } - QTC_ASSERT(m_fi, return); - reportRunResult(*m_fi, success); - m_fi = nullptr; // do not delete, it is not ours + emit finished(success); m_job->deleteLater(); m_job = nullptr; } void QbsInstallStep::handleTaskStarted(const QString &desciption, int max) { - Q_UNUSED(desciption); - QTC_ASSERT(m_fi, return); - m_progressBase = m_fi->progressValue(); - m_fi->setProgressRange(0, m_progressBase + max); + m_description = desciption; + m_maxProgress = max; } void QbsInstallStep::handleProgress(int value) { - QTC_ASSERT(m_fi, return); - m_fi->setProgressValue(m_progressBase + value); + if (m_maxProgress > 0) + emit progress(value * 100 / m_maxProgress, m_description); } void QbsInstallStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, |