aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nim
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2019-01-25 14:26:34 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2019-01-31 16:10:01 +0000
commit966f4ea6a9d1e46833fc30df878ba6fa8f919988 (patch)
tree7f37c2adcf4dd6fe002585fb3b3c2815b21c5f26 /src/plugins/nim
parent536618b012b44b5ced428fc39600931803d5dd44 (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/nim')
-rw-r--r--src/plugins/nim/project/nimcompilercleanstep.cpp15
-rw-r--r--src/plugins/nim/project/nimcompilercleanstep.h6
2 files changed, 14 insertions, 7 deletions
diff --git a/src/plugins/nim/project/nimcompilercleanstep.cpp b/src/plugins/nim/project/nimcompilercleanstep.cpp
index 85df3084452..f07f5011062 100644
--- a/src/plugins/nim/project/nimcompilercleanstep.cpp
+++ b/src/plugins/nim/project/nimcompilercleanstep.cpp
@@ -61,28 +61,33 @@ bool NimCompilerCleanStep::init()
return result;
}
-void NimCompilerCleanStep::run(QFutureInterface<bool> &fi)
+void NimCompilerCleanStep::doRun()
{
if (!m_buildDir.exists()) {
emit addOutput(tr("Build directory \"%1\" does not exist.").arg(m_buildDir.toUserOutput()), BuildStep::OutputFormat::ErrorMessage);
- reportRunResult(fi, false);
+ emit finished(false);
return;
}
if (!removeCacheDirectory()) {
emit addOutput(tr("Failed to delete the cache directory."), BuildStep::OutputFormat::ErrorMessage);
- reportRunResult(fi, false);
+ emit finished(false);
return;
}
if (!removeOutFilePath()) {
emit addOutput(tr("Failed to delete the out file."), BuildStep::OutputFormat::ErrorMessage);
- reportRunResult(fi, false);
+ emit finished(false);
return;
}
emit addOutput(tr("Clean step completed successfully."), BuildStep::OutputFormat::NormalMessage);
- reportRunResult(fi, true);
+ emit finished(true);
+}
+
+void NimCompilerCleanStep::doCancel()
+{
+ // Can be left empty. The run() function hardly does anything.
}
bool NimCompilerCleanStep::removeCacheDirectory()
diff --git a/src/plugins/nim/project/nimcompilercleanstep.h b/src/plugins/nim/project/nimcompilercleanstep.h
index 1e062591bd1..e250d88f452 100644
--- a/src/plugins/nim/project/nimcompilercleanstep.h
+++ b/src/plugins/nim/project/nimcompilercleanstep.h
@@ -39,10 +39,12 @@ public:
NimCompilerCleanStep(ProjectExplorer::BuildStepList *parentList);
ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override;
- bool init() override;
- void run(QFutureInterface<bool> &fi) override;
private:
+ bool init() override;
+ void doRun() override;
+ void doCancel() override;
+
bool removeCacheDirectory();
bool removeOutFilePath();