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/projectexplorer/abstractprocessstep.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/projectexplorer/abstractprocessstep.cpp')
-rw-r--r-- | src/plugins/projectexplorer/abstractprocessstep.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/plugins/projectexplorer/abstractprocessstep.cpp b/src/plugins/projectexplorer/abstractprocessstep.cpp index a2f2e752ee..e85a9648ec 100644 --- a/src/plugins/projectexplorer/abstractprocessstep.cpp +++ b/src/plugins/projectexplorer/abstractprocessstep.cpp @@ -104,7 +104,6 @@ public: Private(AbstractProcessStep *q) : q(q) {} AbstractProcessStep *q; - QFutureInterface<bool> *m_futureInterface = nullptr; std::unique_ptr<Utils::QtcProcess> m_process; std::unique_ptr<IOutputParser> m_outputParserChain; ProcessParameters m_param; @@ -125,7 +124,6 @@ AbstractProcessStep::AbstractProcessStep(BuildStepList *bsl, Core::Id id) : BuildStep(bsl, id), d(new Private(this)) { - setRunInGuiThread(true); } AbstractProcessStep::~AbstractProcessStep() @@ -209,7 +207,7 @@ bool AbstractProcessStep::init() YourBuildStep::run(). */ -void AbstractProcessStep::run(QFutureInterface<bool> &fi) +void AbstractProcessStep::doRun() { QDir wd(d->m_param.effectiveWorkingDirectory()); if (!wd.exists()) { @@ -217,7 +215,7 @@ void AbstractProcessStep::run(QFutureInterface<bool> &fi) emit addOutput(tr("Could not create directory \"%1\"") .arg(QDir::toNativeSeparators(wd.absolutePath())), BuildStep::OutputFormat::ErrorMessage); - reportRunResult(fi, false); + finish(false); return; } } @@ -225,12 +223,10 @@ void AbstractProcessStep::run(QFutureInterface<bool> &fi) QString effectiveCommand = d->m_param.effectiveCommand(); if (!QFileInfo::exists(effectiveCommand)) { processStartupFailed(); - reportRunResult(fi, false); + finish(false); return; } - d->m_futureInterface = &fi; - d->m_process.reset(new Utils::QtcProcess()); d->m_process->setUseCtrlCStub(Utils::HostOsInfo::isWindowsHost()); d->m_process->setWorkingDirectory(wd.absolutePath()); @@ -249,13 +245,13 @@ void AbstractProcessStep::run(QFutureInterface<bool> &fi) processStartupFailed(); d->m_process.reset(); d->m_outputParserChain.reset(); - reportRunResult(fi, false); + finish(false); return; } processStarted(); } -void AbstractProcessStep::cancel() +void AbstractProcessStep::doCancel() { Core::Reaper::reap(d->m_process.release()); } @@ -275,7 +271,7 @@ void AbstractProcessStep::cleanUp(QProcess *process) d->m_process.reset(); // Report result - reportRunResult(*d->m_futureInterface, returnValue); + finish(returnValue); } /*! @@ -420,9 +416,9 @@ void AbstractProcessStep::stdError(const QString &line) emit addOutput(line, BuildStep::OutputFormat::Stderr, BuildStep::DontAppendNewline); } -QFutureInterface<bool> *AbstractProcessStep::futureInterface() const +void AbstractProcessStep::finish(bool success) { - return d->m_futureInterface; + emit finished(success); } void AbstractProcessStep::taskAdded(const Task &task, int linkedOutputLines, int skipLines) |