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::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 task = QtConcurrent::run(&ShellCommand::run, this); + QFuture task = Utils::runAsync(&ShellCommand::run, this); d->m_watcher.setFuture(task); - connect(&d->m_watcher, &QFutureWatcher::canceled, this, &ShellCommand::cancel); - addTask(task); } @@ -305,9 +304,12 @@ void ShellCommand::run(QFutureInterface &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)