diff options
author | Jarek Kobus <[email protected]> | 2023-03-04 00:39:50 +0100 |
---|---|---|
committer | Jarek Kobus <[email protected]> | 2023-03-09 08:40:57 +0000 |
commit | ce037d09a2a85ee06840cd4de2804e1b967dd90b (patch) | |
tree | 61960c0f31a144617525d96dda5eec9d696c04a1 /src/plugins/clearcase/clearcasesync.cpp | |
parent | cae18f88724cff430fb2a54ab0811c751723b6d4 (diff) |
VcsBase: Use QtConcurrent invocation for async run
Change-Id: Ia4e461c1a2e71d4c959f582e9ed464d4713b672a
Reviewed-by: Orgad Shaneh <[email protected]>
Reviewed-by: <[email protected]>
Reviewed-by: Qt CI Bot <[email protected]>
Diffstat (limited to 'src/plugins/clearcase/clearcasesync.cpp')
-rw-r--r-- | src/plugins/clearcase/clearcasesync.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/plugins/clearcase/clearcasesync.cpp b/src/plugins/clearcase/clearcasesync.cpp index 388ce1a8c18..90dad2b988c 100644 --- a/src/plugins/clearcase/clearcasesync.cpp +++ b/src/plugins/clearcase/clearcasesync.cpp @@ -13,6 +13,8 @@ #include <utils/qtcassert.h> #include <utils/qtcprocess.h> +#include <QPromise> + #ifdef WITH_TESTS #include <QTest> #include <utils/fileutils.h> @@ -22,8 +24,7 @@ using namespace Utils; namespace ClearCase::Internal { -static void runProcess(QFutureInterface<void> &future, - const ClearCaseSettings &settings, +static void runProcess(QPromise<void> &promise, const ClearCaseSettings &settings, const QStringList &args, std::function<void(const QString &buffer, int processed)> processLine) { @@ -37,7 +38,7 @@ static void runProcess(QFutureInterface<void> &future, int processed = 0; QString buffer; - while (process.waitForReadyRead() && !future.isCanceled()) { + while (process.waitForReadyRead() && !promise.isCanceled()) { buffer += QString::fromLocal8Bit(process.readAllRawStandardOutput()); int index = buffer.indexOf('\n'); while (index != -1) { @@ -135,7 +136,7 @@ void ClearCaseSync::updateStatusForNotManagedFiles(const QStringList &files) } } -void ClearCaseSync::syncSnapshotView(QFutureInterface<void> &future, QStringList &files, +void ClearCaseSync::syncSnapshotView(QPromise<void> &promise, QStringList &files, const ClearCaseSettings &settings) { const QString view = ClearCasePlugin::viewData().name; @@ -167,18 +168,18 @@ void ClearCaseSync::syncSnapshotView(QFutureInterface<void> &future, QStringList // adding 1 for initial sync in which total is not accurate, to prevent finishing // (we don't want it to become green) - future.setProgressRange(0, totalFileCount + 1); + promise.setProgressRange(0, totalFileCount + 1); int totalProcessed = 0; - runProcess(future, settings, args, [&](const QString &buffer, int processed) { + runProcess(promise, settings, args, [&](const QString &buffer, int processed) { processCleartoolLsLine(viewRootDir, buffer); - future.setProgressValue(qMin(totalFileCount, processed)); + promise.setProgressValue(qMin(totalFileCount, processed)); totalProcessed = processed; }); - if (!future.isCanceled()) { + if (!promise.isCanceled()) { updateStatusForNotManagedFiles(files); - future.setProgressValue(totalFileCount + 1); + promise.setProgressValue(totalFileCount + 1); if (!hot) updateTotalFilesCount(view, settings, totalProcessed); } @@ -193,21 +194,20 @@ void ClearCaseSync::processCleartoolLscheckoutLine(const QString &buffer) /// /// Update the file status for dynamic views. /// -void ClearCaseSync::syncDynamicView(QFutureInterface<void> &future, - const ClearCaseSettings& settings) +void ClearCaseSync::syncDynamicView(QPromise<void> &promise, const ClearCaseSettings& settings) { // Always invalidate status for all files invalidateStatusAllFiles(); const QStringList args({"lscheckout", "-avobs", "-me", "-cview", "-s"}); - runProcess(future, settings, args, [&](const QString &buffer, int processed) { + runProcess(promise, settings, args, [&](const QString &buffer, int processed) { processCleartoolLscheckoutLine(buffer); - future.setProgressValue(processed); + promise.setProgressValue(processed); }); } -void ClearCaseSync::run(QFutureInterface<void> &future, QStringList &files) +void ClearCaseSync::run(QPromise<void> &promise, QStringList &files) { ClearCaseSettings settings = ClearCasePlugin::settings(); if (settings.disableIndexer) @@ -225,9 +225,9 @@ void ClearCaseSync::run(QFutureInterface<void> &future, QStringList &files) emit updateStreamAndView(); if (ClearCasePlugin::viewData().isDynamic) - syncDynamicView(future, settings); + syncDynamicView(promise, settings); else - syncSnapshotView(future, files, settings); + syncSnapshotView(promise, files, settings); } #ifdef WITH_TESTS |