aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/shellcommand.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@theqtcompany.com>2016-01-25 15:55:33 +0100
committerEike Ziller <eike.ziller@theqtcompany.com>2016-01-26 10:27:09 +0000
commit4659f2caca7c4b716a02b3121ccf9240f32090a8 (patch)
treed857d9159764d31f2250b11f44678d4413cc6e86 /src/libs/utils/shellcommand.cpp
parentd35f4fb72ddafc2472a266cf281ad52948ecdf5e (diff)
ShellCommand: Some tweaks of QtConcurrent usage
Use Utils::runAsync to avoid use of global thread pool. Move watcher connect to constructor. Report "failure" of the command by internally canceling. Change-Id: Ib7616734176be2ad9356162724ca06cfd8821e52 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Diffstat (limited to 'src/libs/utils/shellcommand.cpp')
-rw-r--r--src/libs/utils/shellcommand.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/libs/utils/shellcommand.cpp b/src/libs/utils/shellcommand.cpp
index 62e7a35aec6..1968f56f5fc 100644
--- a/src/libs/utils/shellcommand.cpp
+++ b/src/libs/utils/shellcommand.cpp
@@ -140,7 +140,9 @@ ShellCommandPrivate::Job::Job(const QString &wd, const Utils::FileName &b, const
ShellCommand::ShellCommand(const QString &workingDirectory,
const QProcessEnvironment &environment) :
d(new Internal::ShellCommandPrivate(workingDirectory, environment))
-{ }
+{
+ connect(&d->m_watcher, &QFutureWatcher<void>::canceled, this, &ShellCommand::cancel);
+}
ShellCommand::~ShellCommand()
{
@@ -223,11 +225,8 @@ void ShellCommand::execute()
if (d->m_jobs.empty())
return;
- // For some reason QtConcurrent::run() only works on this
- QFuture<void> task = QtConcurrent::run(&ShellCommand::run, this);
+ QFuture<void> task = Utils::runAsync<void>(&ShellCommand::run, this);
d->m_watcher.setFuture(task);
- connect(&d->m_watcher, &QFutureWatcher<void>::canceled, this, &ShellCommand::cancel);
-
addTask(task);
}
@@ -305,9 +304,12 @@ void ShellCommand::run(QFutureInterface<void> &future)
}
emit finished(d->m_lastExecSuccess, d->m_lastExecExitCode, cookie());
- if (d->m_lastExecSuccess)
+ if (d->m_lastExecSuccess) {
emit success(cookie());
- future.setProgressValue(future.progressMaximum());
+ future.setProgressValue(future.progressMaximum());
+ } else {
+ future.cancel(); // sets the progress indicator red
+ }
}
if (d->m_progressParser)