VcsBaseDiffEditorController: Remove unused stuff

Change-Id: I34cc9dee686929fb69253ba16ff0fd5fed023ca1
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
2022-12-15 14:53:08 +01:00
parent 2d285bc808
commit df2d68eb4f
7 changed files with 13 additions and 152 deletions

View File

@@ -2,25 +2,15 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#include "vcsbasediffeditorcontroller.h"
#include "vcsbaseclient.h"
#include "vcscommand.h"
#include "vcsplugin.h"
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <utils/asynctask.h>
#include <utils/commandline.h>
#include <utils/environment.h>
#include <utils/futuresynchronizer.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <utils/runextensions.h>
#include <QPointer>
using namespace DiffEditor;
using namespace Core;
using namespace Utils;
namespace VcsBase {
@@ -38,92 +28,13 @@ class VcsBaseDiffEditorControllerPrivate
{
public:
VcsBaseDiffEditorControllerPrivate(VcsBaseDiffEditorController *q) : q(q) {}
~VcsBaseDiffEditorControllerPrivate();
void processingFinished();
void processDiff(const QString &patch);
void cancelReload();
void commandFinished(bool success);
VcsBaseDiffEditorController *q;
Environment m_processEnvironment;
FilePath m_vcsBinary;
int m_vscTimeoutS;
QPointer<VcsCommand> m_command;
QFutureWatcher<QList<FileData>> *m_processWatcher = nullptr;
const Tasking::TreeStorage<QString> m_inputStorage;
};
VcsBaseDiffEditorControllerPrivate::~VcsBaseDiffEditorControllerPrivate()
{
delete m_command;
cancelReload();
}
void VcsBaseDiffEditorControllerPrivate::processingFinished()
{
QTC_ASSERT(m_processWatcher, return);
// success is false when the user clicked the cancel micro button
// inside the progress indicator
const bool success = !m_processWatcher->future().isCanceled();
const QList<FileData> fileDataList = success
? m_processWatcher->future().result() : QList<FileData>();
// Prevent direct deletion of m_processWatcher since
// processingFinished() is called directly by the m_processWatcher.
m_processWatcher->deleteLater();
m_processWatcher = nullptr;
q->setDiffFiles(fileDataList);
q->reloadFinished(success);
}
void VcsBaseDiffEditorControllerPrivate::processDiff(const QString &patch)
{
cancelReload();
m_processWatcher = new QFutureWatcher<QList<FileData>>();
QObject::connect(m_processWatcher, &QFutureWatcherBase::finished,
q, [this] { processingFinished(); });
m_processWatcher->setFuture(Utils::runAsync(&readPatch, patch));
ProgressManager::addTask(m_processWatcher->future(),
VcsBaseDiffEditorController::tr("Processing diff"), "DiffEditor");
}
void VcsBaseDiffEditorControllerPrivate::cancelReload()
{
m_command.clear();
if (m_processWatcher) {
// Cancel the running process without the further processingFinished()
// notification for this process.
m_processWatcher->future().cancel();
delete m_processWatcher;
m_processWatcher = nullptr;
}
}
void VcsBaseDiffEditorControllerPrivate::commandFinished(bool success)
{
const QString output = m_command->cleanedStdOut();
// Don't delete here, as it is called from command finished signal.
// Clear it only, as we may call runCommand() again from inside processCommandOutput overload.
m_command.clear();
if (!success) {
cancelReload();
q->reloadFinished(success);
return;
}
q->processCommandOutput(output);
}
/////////////////////
VcsBaseDiffEditorController::VcsBaseDiffEditorController(Core::IDocument *document)
@@ -169,42 +80,6 @@ void VcsBaseDiffEditorController::setupCommand(QtcProcess &process, const QStrin
process.setCommand({d->m_vcsBinary, args});
}
void VcsBaseDiffEditorController::runCommand(const QList<QStringList> &args, RunFlags flags, QTextCodec *codec)
{
// Cancel the possible ongoing reload without the commandFinished() nor
// processingFinished() notifications, as right after that
// we re-reload it from scratch. So no intermediate "Retrieving data failed."
// and "Waiting for data..." will be shown.
delete d->m_command;
d->cancelReload();
d->m_command = VcsBaseClient::createVcsCommand(workingDirectory(), d->m_processEnvironment);
d->m_command->setDisplayName(displayName());
d->m_command->setCodec(codec ? codec : EditorManager::defaultTextCodec());
connect(d->m_command.data(), &VcsCommand::done, this, [this] {
d->commandFinished(d->m_command->result() == ProcessResult::FinishedWithSuccess);
});
d->m_command->addFlags(flags);
for (const QStringList &arg : args) {
QTC_ASSERT(!arg.isEmpty(), continue);
d->m_command->addJob({d->m_vcsBinary, arg}, d->m_vscTimeoutS);
}
d->m_command->start();
}
void VcsBaseDiffEditorController::processCommandOutput(const QString &output)
{
d->processDiff(output);
}
void VcsBaseDiffEditorController::setVcsTimeoutS(int value)
{
d->m_vscTimeoutS = value;
}
void VcsBaseDiffEditorController::setVcsBinary(const FilePath &path)
{
d->m_vcsBinary = path;