VcsCommand: Create ProgressTimer manually

The QFutureInterface<void>::get() method was introduced
in 6.3, so we can't use it yet. Create ProgressTimer
manually in the caller thread for the future passed to
ProgressManager::addTask().

Amends a5683616b9

Change-Id: I1f96c433e759d66eaaa1a32489e9db4facecf46a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Jarek Kobus
2022-08-03 15:14:49 +02:00
parent 55722ac5a4
commit a714ddf59f

View File

@@ -30,6 +30,7 @@
#include "vcsplugin.h" #include "vcsplugin.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/progressmanager/futureprogress.h>
#include <coreplugin/progressmanager/progressmanager.h> #include <coreplugin/progressmanager/progressmanager.h>
#include <utils/environment.h> #include <utils/environment.h>
@@ -105,6 +106,7 @@ public:
QTextCodec *m_codec = nullptr; QTextCodec *m_codec = nullptr;
ProgressParser *m_progressParser = nullptr; ProgressParser *m_progressParser = nullptr;
QFutureWatcher<void> m_watcher; QFutureWatcher<void> m_watcher;
FutureProgress *m_futureProgress = nullptr;
QList<Job> m_jobs; QList<Job> m_jobs;
unsigned m_flags = 0; unsigned m_flags = 0;
@@ -144,13 +146,7 @@ void VcsCommand::addTask(const QFuture<void> &future)
const QString name = displayName(); const QString name = displayName();
const auto id = Id::fromString(name + QLatin1String(".action")); const auto id = Id::fromString(name + QLatin1String(".action"));
if (d->m_progressParser) { d->m_futureProgress = ProgressManager::addTask(future, name, id);
ProgressManager::addTask(future, name, id);
} else {
ProgressManager::addTimedTask(QFutureInterface<void>::get(future), name, id,
qMax(2, timeoutS() / 5));
}
Internal::VcsPlugin::addFuture(future); Internal::VcsPlugin::addFuture(future);
} }
@@ -249,10 +245,14 @@ void VcsCommand::run(QFutureInterface<void> &future)
GlobalFileChangeBlocker::instance()->forceBlocked(true); GlobalFileChangeBlocker::instance()->forceBlocked(true);
}); });
} }
if (d->m_progressParser) if (d->m_progressParser) {
d->m_progressParser->setFuture(&future); d->m_progressParser->setFuture(&future);
else } else {
future.setProgressRange(0, 1); QMetaObject::invokeMethod(this, [this, future] {
(void) new ProgressTimer(future, qMax(2, timeoutS() / 5), d->m_futureProgress);
});
}
const int count = d->m_jobs.size(); const int count = d->m_jobs.size();
bool lastExecSuccess = true; bool lastExecSuccess = true;
for (int j = 0; j < count; j++) { for (int j = 0; j < count; j++) {