aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/buildgraph/executorjob.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2014-04-11 13:40:17 +0200
committerChristian Kandeler <christian.kandeler@digia.com>2014-04-15 14:18:55 +0200
commit637249a8c1ef722c5646e1ca85d516f88a1a1dc6 (patch)
tree89f8322163bb810a048e5c4e211fe69193e4cd0f /src/lib/corelib/buildgraph/executorjob.cpp
parentfdc392858716c390f1541430dad3bb6aefdf792e (diff)
Allow long-running commands to be canceled.
At the moment, canceling a build waits for the current command to finish, which means that a badly behaving process or piece of JavaScript code can block qbs indefinitely. Task-number: QBS-552 Change-Id: I8ac23f068dd6083905a9681097da6b970c0b646b Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/lib/corelib/buildgraph/executorjob.cpp')
-rw-r--r--src/lib/corelib/buildgraph/executorjob.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/lib/corelib/buildgraph/executorjob.cpp b/src/lib/corelib/buildgraph/executorjob.cpp
index 1ad82cdb5..e2ed11ba2 100644
--- a/src/lib/corelib/buildgraph/executorjob.cpp
+++ b/src/lib/corelib/buildgraph/executorjob.cpp
@@ -96,18 +96,9 @@ void ExecutorJob::run(Transformer *t)
void ExecutorJob::cancel()
{
- if (!m_transformer)
- return;
- if (m_currentCommandIdx < m_transformer->commands.count() - 1) {
- m_error = ErrorInfo(tr("Transformer execution canceled."));
- m_currentCommandIdx = m_transformer->commands.count();
- }
-}
-
-void ExecutorJob::waitForFinished()
-{
- if (m_currentCommandExecutor)
- m_currentCommandExecutor->waitForFinished();
+ QBS_ASSERT(m_currentCommandExecutor, return);
+ m_error = ErrorInfo(tr("Transformer execution canceled."));
+ m_currentCommandExecutor->cancel();
}
void ExecutorJob::runNextCommand()
@@ -137,7 +128,9 @@ void ExecutorJob::runNextCommand()
void ExecutorJob::onCommandFinished(const ErrorInfo &err)
{
QBS_ASSERT(m_transformer, return);
- if (err.hasError()) {
+ if (m_error.hasError()) { // Canceled?
+ setFinished();
+ } else if (err.hasError()) {
m_error = err;
setFinished();
} else {