VcsBaseDiffEditorController: Get rid of inputStorage() method

Pass explicitly the storage to the postProcessTask() instead.

Change-Id: I75ac10969530dfea1eac266b44481be3b1d8249b
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Jarek Kobus
2023-08-02 20:12:04 +02:00
parent d060d1b224
commit 6845434f3d
5 changed files with 14 additions and 24 deletions

View File

@@ -238,7 +238,7 @@ GitDiffEditorController::GitDiffEditorController(IDocument *document,
{ {
using namespace Tasking; using namespace Tasking;
const TreeStorage<QString> diffInputStorage = inputStorage(); const TreeStorage<QString> diffInputStorage;
const auto setupDiff = [=](Process &process) { const auto setupDiff = [=](Process &process) {
process.setCodec(VcsBaseEditor::getCodec(workingDirectory(), {})); process.setCodec(VcsBaseEditor::getCodec(workingDirectory(), {}));
@@ -252,7 +252,7 @@ GitDiffEditorController::GitDiffEditorController(IDocument *document,
const Group root { const Group root {
Storage(diffInputStorage), Storage(diffInputStorage),
ProcessTask(setupDiff, onDiffDone), ProcessTask(setupDiff, onDiffDone),
postProcessTask() postProcessTask(diffInputStorage)
}; };
setReloadRecipe(root); setReloadRecipe(root);
} }
@@ -304,7 +304,7 @@ FileListDiffController::FileListDiffController(IDocument *document, const QStrin
}; };
const TreeStorage<DiffStorage> storage; const TreeStorage<DiffStorage> storage;
const TreeStorage<QString> diffInputStorage = inputStorage(); const TreeStorage<QString> diffInputStorage;
const auto setupStaged = [this, stagedFiles](Process &process) { const auto setupStaged = [this, stagedFiles](Process &process) {
if (stagedFiles.isEmpty()) if (stagedFiles.isEmpty())
@@ -346,7 +346,7 @@ FileListDiffController::FileListDiffController(IDocument *document, const QStrin
ProcessTask(setupUnstaged, onUnstagedDone), ProcessTask(setupUnstaged, onUnstagedDone),
onGroupDone(onStagingDone) onGroupDone(onStagingDone)
}, },
postProcessTask() postProcessTask(diffInputStorage)
}; };
setReloadRecipe(root); setReloadRecipe(root);
} }
@@ -377,7 +377,7 @@ ShowController::ShowController(IDocument *document, const QString &id)
}; };
const TreeStorage<ReloadStorage> storage; const TreeStorage<ReloadStorage> storage;
const TreeStorage<QString> diffInputStorage = inputStorage(); const TreeStorage<QString> diffInputStorage;
const auto updateDescription = [this](const ReloadStorage &storage) { const auto updateDescription = [this](const ReloadStorage &storage) {
QString desc = storage.m_header; QString desc = storage.m_header;
@@ -552,7 +552,7 @@ ShowController::ShowController(IDocument *document, const QString &id)
}, },
Group { Group {
ProcessTask(setupDiff, onDiffDone), ProcessTask(setupDiff, onDiffDone),
postProcessTask() postProcessTask(diffInputStorage)
} }
}; };
setReloadRecipe(root); setReloadRecipe(root);

View File

@@ -53,7 +53,7 @@ MercurialDiffEditorController::MercurialDiffEditorController(IDocument *document
using namespace Tasking; using namespace Tasking;
const TreeStorage<QString> diffInputStorage = inputStorage(); const TreeStorage<QString> diffInputStorage;
const auto setupDiff = [=](Process &process) { const auto setupDiff = [=](Process &process) {
setupCommand(process, {addConfigurationArguments(args)}); setupCommand(process, {addConfigurationArguments(args)});
@@ -66,7 +66,7 @@ MercurialDiffEditorController::MercurialDiffEditorController(IDocument *document
const Group root { const Group root {
Storage(diffInputStorage), Storage(diffInputStorage),
ProcessTask(setupDiff, onDiffDone), ProcessTask(setupDiff, onDiffDone),
postProcessTask() postProcessTask(diffInputStorage)
}; };
setReloadRecipe(root); setReloadRecipe(root);
} }

View File

@@ -163,7 +163,7 @@ SubversionDiffEditorController::SubversionDiffEditorController(IDocument *docume
using namespace Tasking; using namespace Tasking;
const TreeStorage<QString> diffInputStorage = inputStorage(); const TreeStorage<QString> diffInputStorage;
const auto setupDescription = [this](Process &process) { const auto setupDescription = [this](Process &process) {
if (m_changeNumber == 0) if (m_changeNumber == 0)
@@ -209,7 +209,7 @@ SubversionDiffEditorController::SubversionDiffEditorController(IDocument *docume
}, },
Group { Group {
ProcessTask(setupDiff, onDiffDone), ProcessTask(setupDiff, onDiffDone),
postProcessTask() postProcessTask(diffInputStorage)
} }
}; };
setReloadRecipe(root); setReloadRecipe(root);

View File

@@ -40,20 +40,11 @@ VcsBaseDiffEditorController::~VcsBaseDiffEditorController()
delete d; delete d;
} }
TreeStorage<QString> VcsBaseDiffEditorController::inputStorage() const GroupItem VcsBaseDiffEditorController::postProcessTask(const TreeStorage<QString> &inputStorage)
{ {
return d->m_inputStorage; const auto setupDiffProcessor = [inputStorage](Async<QList<FileData>> &async) {
}
GroupItem VcsBaseDiffEditorController::postProcessTask()
{
const auto setupDiffProcessor = [this](Async<QList<FileData>> &async) {
const QString *storage = inputStorage().activeStorage();
QTC_ASSERT(storage, qWarning("Using postProcessTask() requires putting inputStorage() "
"into task tree's root group."));
const QString inputData = storage ? *storage : QString();
async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer());
async.setConcurrentCallData(&DiffUtils::readPatchWithPromise, inputData); async.setConcurrentCallData(&DiffUtils::readPatchWithPromise, *inputStorage);
}; };
const auto onDiffProcessorDone = [this](const Async<QList<FileData>> &async) { const auto onDiffProcessorDone = [this](const Async<QList<FileData>> &async) {
setDiffFiles(async.isResultAvailable() ? async.result() : QList<FileData>()); setDiffFiles(async.isResultAvailable() ? async.result() : QList<FileData>());

View File

@@ -28,8 +28,7 @@ public:
void setVcsBinary(const Utils::FilePath &path); void setVcsBinary(const Utils::FilePath &path);
protected: protected:
Tasking::TreeStorage<QString> inputStorage() const; Tasking::GroupItem postProcessTask(const Tasking::TreeStorage<QString> &inputStorage);
Tasking::GroupItem postProcessTask();
void setupCommand(Utils::Process &process, const QStringList &args) const; void setupCommand(Utils::Process &process, const QStringList &args) const;