VcsPlugin: Use VcsCommand::done() signal instead of finished()

Conform to QtcProcess interface. Use result() when needed.

Change-Id: Idd4c71d9a103e8649b08ec7787c2f286423a31ec
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Jarek Kobus
2022-09-19 12:08:38 +02:00
parent 5e10ea19c1
commit b795bd8042
7 changed files with 65 additions and 63 deletions

View File

@@ -420,7 +420,7 @@ bool BranchView::checkout()
const bool moveChanges = branchCheckoutDialog.moveLocalChangesToNextBranch(); const bool moveChanges = branchCheckoutDialog.moveLocalChangesToNextBranch();
const bool popStash = branchCheckoutDialog.popStashOfNextBranch(); const bool popStash = branchCheckoutDialog.popStashOfNextBranch();
if (command && (moveChanges || popStash)) { if (command && (moveChanges || popStash)) {
connect(command, &VcsCommand::finished, connect(command, &VcsCommand::done,
this, [this, client, popMessageStart, moveChanges, popStash] { this, [this, client, popMessageStart, moveChanges, popStash] {
if (moveChanges) { if (moveChanges) {
client->endStashScope(m_repository); client->endStashScope(m_repository);

View File

@@ -320,7 +320,7 @@ void GitBaseDiffEditorController::updateBranchList()
VcsCommand *command = m_instance->vcsExec(baseDirectory(), VcsCommand *command = m_instance->vcsExec(baseDirectory(),
{"branch", noColorOption, "-a", "--contains", revision}); {"branch", noColorOption, "-a", "--contains", revision});
connect(command, &VcsCommand::finished, this, [this, command] { connect(command, &VcsCommand::done, this, [this, command] {
const QString remotePrefix = "remotes/"; const QString remotePrefix = "remotes/";
const QString localPrefix = "<Local>"; const QString localPrefix = "<Local>";
const int prefixLength = remotePrefix.length(); const int prefixLength = remotePrefix.length();
@@ -731,7 +731,7 @@ public:
handler->setParent(command); // delete when command goes out of scope handler->setParent(command); // delete when command goes out of scope
command->addFlags(VcsCommand::ExpectRepoChanges); command->addFlags(VcsCommand::ExpectRepoChanges);
connect(command, &VcsCommand::finished, handler, [handler, command] { connect(command, &VcsCommand::done, handler, [handler, command] {
handler->readStdOut(command->cleanedStdOut()); handler->readStdOut(command->cleanedStdOut());
handler->readStdErr(command->cleanedStdErr()); handler->readStdErr(command->cleanedStdErr());
}); });
@@ -1133,7 +1133,7 @@ void GitClient::status(const FilePath &workingDirectory) const
{ {
VcsOutputWindow::setRepository(workingDirectory); VcsOutputWindow::setRepository(workingDirectory);
VcsCommand *command = vcsExec(workingDirectory, {"status", "-u"}, nullptr, true); VcsCommand *command = vcsExec(workingDirectory, {"status", "-u"}, nullptr, true);
connect(command, &VcsCommand::finished, VcsOutputWindow::instance(), connect(command, &VcsCommand::done, VcsOutputWindow::instance(),
&VcsOutputWindow::clearRepository, Qt::QueuedConnection); &VcsOutputWindow::clearRepository, Qt::QueuedConnection);
} }
@@ -1378,11 +1378,10 @@ VcsCommand *GitClient::checkout(const FilePath &workingDirectory, const QString
VcsCommand *command = vcsExec( VcsCommand *command = vcsExec(
workingDirectory, arguments, nullptr, true, workingDirectory, arguments, nullptr, true,
VcsCommand::ExpectRepoChanges | VcsCommand::ShowSuccessMessage); VcsCommand::ExpectRepoChanges | VcsCommand::ShowSuccessMessage);
connect(command, &VcsCommand::finished, connect(command, &VcsCommand::done, this, [this, workingDirectory, stashMode, command] {
this, [this, workingDirectory, stashMode](bool success) {
if (stashMode == StashMode::TryStash) if (stashMode == StashMode::TryStash)
endStashScope(workingDirectory); endStashScope(workingDirectory);
if (success) if (command->result() == ProcessResult::FinishedWithSuccess)
updateSubmodulesIfNeeded(workingDirectory, true); updateSubmodulesIfNeeded(workingDirectory, true);
}); });
return command; return command;
@@ -1490,8 +1489,8 @@ void GitClient::removeStaleRemoteBranches(const FilePath &workingDirectory, cons
VcsCommand *command = vcsExec(workingDirectory, arguments, nullptr, true, VcsCommand *command = vcsExec(workingDirectory, arguments, nullptr, true,
VcsCommand::ShowSuccessMessage); VcsCommand::ShowSuccessMessage);
connect(command, &VcsCommand::finished, this, [workingDirectory](bool success) { connect(command, &VcsCommand::done, this, [workingDirectory, command] {
if (success) if (command->result() == ProcessResult::FinishedWithSuccess)
GitPlugin::updateBranches(workingDirectory); GitPlugin::updateBranches(workingDirectory);
}); });
} }
@@ -2319,7 +2318,7 @@ void GitClient::updateSubmodulesIfNeeded(const FilePath &workingDirectory, bool
VcsCommand *cmd = vcsExec(workingDirectory, {"submodule", "update"}, nullptr, true, VcsCommand *cmd = vcsExec(workingDirectory, {"submodule", "update"}, nullptr, true,
VcsCommand::ExpectRepoChanges); VcsCommand::ExpectRepoChanges);
connect(cmd, &VcsCommand::finished, this, &GitClient::finishSubmoduleUpdate); connect(cmd, &VcsCommand::done, this, &GitClient::finishSubmoduleUpdate);
} }
void GitClient::finishSubmoduleUpdate() void GitClient::finishSubmoduleUpdate()
@@ -3095,8 +3094,8 @@ void GitClient::fetch(const FilePath &workingDirectory, const QString &remote)
QStringList const arguments = {"fetch", (remote.isEmpty() ? "--all" : remote)}; QStringList const arguments = {"fetch", (remote.isEmpty() ? "--all" : remote)};
VcsCommand *command = vcsExec(workingDirectory, arguments, nullptr, true, VcsCommand *command = vcsExec(workingDirectory, arguments, nullptr, true,
VcsCommand::ShowSuccessMessage); VcsCommand::ShowSuccessMessage);
connect(command, &VcsCommand::finished, this, [workingDirectory](bool success) { connect(command, &VcsCommand::done, this, [workingDirectory, command] {
if (success) if (command->result() == ProcessResult::FinishedWithSuccess)
GitPlugin::updateBranches(workingDirectory); GitPlugin::updateBranches(workingDirectory);
}); });
} }
@@ -3126,8 +3125,8 @@ void GitClient::pull(const FilePath &workingDirectory, bool rebase)
} }
VcsCommand *command = vcsExecAbortable(workingDirectory, arguments, rebase, abortCommand); VcsCommand *command = vcsExecAbortable(workingDirectory, arguments, rebase, abortCommand);
connect(command, &VcsCommand::finished, this, [this, workingDirectory](bool success) { connect(command, &VcsCommand::done, this, [this, workingDirectory, command] {
if (success) if (command->result() == ProcessResult::FinishedWithSuccess)
updateSubmodulesIfNeeded(workingDirectory, true); updateSubmodulesIfNeeded(workingDirectory, true);
}, Qt::QueuedConnection); }, Qt::QueuedConnection);
} }
@@ -3263,11 +3262,11 @@ public:
nullptr, true, VcsCommand::ShowSuccessMessage); nullptr, true, VcsCommand::ShowSuccessMessage);
// Make command a parent of this in order to delete this when command is deleted // Make command a parent of this in order to delete this when command is deleted
setParent(command); setParent(command);
connect(command, &VcsCommand::finished, this, [=](bool success) { connect(command, &VcsCommand::done, this, [=] {
QString pushFallbackCommand; QString pushFallbackCommand;
const PushFailure pushFailure = handleError(command->cleanedStdErr(), const PushFailure pushFailure = handleError(command->cleanedStdErr(),
&pushFallbackCommand); &pushFallbackCommand);
if (success) { if (command->result() == ProcessResult::FinishedWithSuccess) {
GitPlugin::updateCurrentBranch(); GitPlugin::updateCurrentBranch();
return; return;
} }
@@ -3288,8 +3287,8 @@ public:
VcsCommand *rePushCommand = m_gitClient->vcsExec(workingDir, VcsCommand *rePushCommand = m_gitClient->vcsExec(workingDir,
QStringList({"push", "--force-with-lease"}) + pushArgs, QStringList({"push", "--force-with-lease"}) + pushArgs,
nullptr, true, VcsCommand::ShowSuccessMessage); nullptr, true, VcsCommand::ShowSuccessMessage);
connect(rePushCommand, &VcsCommand::finished, this, [](bool success) { connect(rePushCommand, &VcsCommand::done, this, [rePushCommand] {
if (success) if (rePushCommand->result() == ProcessResult::FinishedWithSuccess)
GitPlugin::updateCurrentBranch(); GitPlugin::updateCurrentBranch();
}); });
return; return;
@@ -3310,8 +3309,8 @@ public:
pushFallbackCommand.split(' ', Qt::SkipEmptyParts); pushFallbackCommand.split(' ', Qt::SkipEmptyParts);
VcsCommand *rePushCommand = m_gitClient->vcsExec(workingDir, VcsCommand *rePushCommand = m_gitClient->vcsExec(workingDir,
fallbackCommandParts.mid(1), nullptr, true, VcsCommand::ShowSuccessMessage); fallbackCommandParts.mid(1), nullptr, true, VcsCommand::ShowSuccessMessage);
connect(rePushCommand, &VcsCommand::finished, this, [workingDir](bool success) { connect(rePushCommand, &VcsCommand::done, this, [workingDir, rePushCommand] {
if (success) if (rePushCommand->result() == ProcessResult::FinishedWithSuccess)
GitPlugin::updateBranches(workingDir); GitPlugin::updateBranches(workingDir);
}); });
}); });

View File

@@ -40,6 +40,7 @@
#include <QPushButton> #include <QPushButton>
#include <QVBoxLayout> #include <QVBoxLayout>
using namespace Utils;
using namespace VcsBase; using namespace VcsBase;
namespace GitLab { namespace GitLab {
@@ -55,12 +56,12 @@ GitLabCloneDialog::GitLabCloneDialog(const Project &project, QWidget *parent)
m_repositoryCB = new QComboBox(this); m_repositoryCB = new QComboBox(this);
m_repositoryCB->addItems({project.sshUrl, project.httpUrl}); m_repositoryCB->addItems({project.sshUrl, project.httpUrl});
form->addRow(tr("Repository"), m_repositoryCB); form->addRow(tr("Repository"), m_repositoryCB);
m_pathChooser = new Utils::PathChooser(this); m_pathChooser = new PathChooser(this);
m_pathChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory); m_pathChooser->setExpectedKind(PathChooser::ExistingDirectory);
form->addRow(tr("Path"), m_pathChooser); form->addRow(tr("Path"), m_pathChooser);
m_directoryLE = new Utils::FancyLineEdit(this); m_directoryLE = new FancyLineEdit(this);
m_directoryLE->setValidationFunction([this](Utils::FancyLineEdit *e, QString *msg) { m_directoryLE->setValidationFunction([this](FancyLineEdit *e, QString *msg) {
const Utils::FilePath fullPath = m_pathChooser->filePath().pathAppended(e->text()); const FilePath fullPath = m_pathChooser->filePath().pathAppended(e->text());
bool alreadyExists = fullPath.exists(); bool alreadyExists = fullPath.exists();
if (alreadyExists && msg) if (alreadyExists && msg)
*msg = tr("Path \"%1\" already exists.").arg(fullPath.toUserOutput()); *msg = tr("Path \"%1\" already exists.").arg(fullPath.toUserOutput());
@@ -75,7 +76,7 @@ GitLabCloneDialog::GitLabCloneDialog(const Project &project, QWidget *parent)
m_cloneOutput->setReadOnly(true); m_cloneOutput->setReadOnly(true);
centerLayout->addWidget(m_cloneOutput); centerLayout->addWidget(m_cloneOutput);
layout->addLayout(centerLayout); layout->addLayout(centerLayout);
m_infoLabel = new Utils::InfoLabel(this); m_infoLabel = new InfoLabel(this);
layout->addWidget(m_infoLabel); layout->addWidget(m_infoLabel);
auto buttons = new QDialogButtonBox(QDialogButtonBox::Cancel, this); auto buttons = new QDialogButtonBox(QDialogButtonBox::Cancel, this);
m_cloneButton = new QPushButton(tr("Clone"), this); m_cloneButton = new QPushButton(tr("Clone"), this);
@@ -91,11 +92,11 @@ GitLabCloneDialog::GitLabCloneDialog(const Project &project, QWidget *parent)
QTC_ASSERT(slashIndex > 0, return); QTC_ASSERT(slashIndex > 0, return);
m_directoryLE->setText(path.mid(slashIndex + 1)); m_directoryLE->setText(path.mid(slashIndex + 1));
connect(m_pathChooser, &Utils::PathChooser::textChanged, this, [this] { connect(m_pathChooser, &PathChooser::textChanged, this, [this] {
m_directoryLE->validate(); m_directoryLE->validate();
GitLabCloneDialog::updateUi(); GitLabCloneDialog::updateUi();
}); });
connect(m_directoryLE, &Utils::FancyLineEdit::textChanged, this, &GitLabCloneDialog::updateUi); connect(m_directoryLE, &FancyLineEdit::textChanged, this, &GitLabCloneDialog::updateUi);
connect(m_cloneButton, &QPushButton::clicked, this, &GitLabCloneDialog::cloneProject); connect(m_cloneButton, &QPushButton::clicked, this, &GitLabCloneDialog::cloneProject);
connect(m_cancelButton, &QPushButton::clicked, connect(m_cancelButton, &QPushButton::clicked,
this, &GitLabCloneDialog::cancel); this, &GitLabCloneDialog::cancel);
@@ -118,10 +119,10 @@ void GitLabCloneDialog::updateUi()
m_cloneButton->setEnabled(pathValid && directoryValid); m_cloneButton->setEnabled(pathValid && directoryValid);
if (!pathValid) { if (!pathValid) {
m_infoLabel->setText(m_pathChooser->errorMessage()); m_infoLabel->setText(m_pathChooser->errorMessage());
m_infoLabel->setType(Utils::InfoLabel::Error); m_infoLabel->setType(InfoLabel::Error);
} else if (!directoryValid) { } else if (!directoryValid) {
m_infoLabel->setText(m_directoryLE->errorMessage()); m_infoLabel->setText(m_directoryLE->errorMessage());
m_infoLabel->setType(Utils::InfoLabel::Error); m_infoLabel->setType(InfoLabel::Error);
} }
m_infoLabel->setVisible(!pathValid || !directoryValid); m_infoLabel->setVisible(!pathValid || !directoryValid);
} }
@@ -129,14 +130,14 @@ void GitLabCloneDialog::updateUi()
void GitLabCloneDialog::cloneProject() void GitLabCloneDialog::cloneProject()
{ {
VcsBasePluginPrivate *vc = static_cast<VcsBasePluginPrivate *>( VcsBasePluginPrivate *vc = static_cast<VcsBasePluginPrivate *>(
Core::VcsManager::versionControl(Utils::Id::fromString("G.Git"))); Core::VcsManager::versionControl(Id::fromString("G.Git")));
QTC_ASSERT(vc, return); QTC_ASSERT(vc, return);
const QStringList extraArgs = m_submodulesCB->isChecked() ? QStringList{ "--recursive" } const QStringList extraArgs = m_submodulesCB->isChecked() ? QStringList{ "--recursive" }
: QStringList{}; : QStringList{};
m_command = vc->createInitialCheckoutCommand(m_repositoryCB->currentText(), m_command = vc->createInitialCheckoutCommand(m_repositoryCB->currentText(),
m_pathChooser->absoluteFilePath(), m_pathChooser->absoluteFilePath(),
m_directoryLE->text(), extraArgs); m_directoryLE->text(), extraArgs);
const Utils::FilePath workingDirectory = m_pathChooser->absoluteFilePath(); const FilePath workingDirectory = m_pathChooser->absoluteFilePath();
m_command->setProgressiveOutput(true); m_command->setProgressiveOutput(true);
connect(m_command, &VcsCommand::stdOutText, this, [this](const QString &text) { connect(m_command, &VcsCommand::stdOutText, this, [this](const QString &text) {
m_cloneOutput->appendPlainText(text); m_cloneOutput->appendPlainText(text);
@@ -144,7 +145,9 @@ void GitLabCloneDialog::cloneProject()
connect(m_command, &VcsCommand::stdErrText, this, [this](const QString &text) { connect(m_command, &VcsCommand::stdErrText, this, [this](const QString &text) {
m_cloneOutput->appendPlainText(text); m_cloneOutput->appendPlainText(text);
}); });
connect(m_command, &VcsCommand::finished, this, &GitLabCloneDialog::cloneFinished); connect(m_command, &VcsCommand::done, this, [this] {
cloneFinished(m_command->result() == ProcessResult::FinishedWithSuccess);
});
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_cloneOutput->clear(); m_cloneOutput->clear();
@@ -166,12 +169,12 @@ void GitLabCloneDialog::cancel()
} }
} }
static Utils::FilePaths scanDirectoryForFiles(const Utils::FilePath &directory) static FilePaths scanDirectoryForFiles(const FilePath &directory)
{ {
Utils::FilePaths result; FilePaths result;
const Utils::FilePaths entries = directory.dirEntries(QDir::AllEntries | QDir::NoDotAndDotDot); const FilePaths entries = directory.dirEntries(QDir::AllEntries | QDir::NoDotAndDotDot);
for (const Utils::FilePath &entry : entries) { for (const FilePath &entry : entries) {
if (entry.isDir()) if (entry.isDir())
result.append(scanDirectoryForFiles(entry)); result.append(scanDirectoryForFiles(entry));
else else
@@ -194,21 +197,19 @@ void GitLabCloneDialog::cloneFinished(bool success)
m_cloneOutput->appendPlainText(tr("Cloning succeeded.") + emptyLine); m_cloneOutput->appendPlainText(tr("Cloning succeeded.") + emptyLine);
m_cloneButton->setEnabled(false); m_cloneButton->setEnabled(false);
const Utils::FilePath base = m_pathChooser->filePath().pathAppended(m_directoryLE->text()); const FilePath base = m_pathChooser->filePath().pathAppended(m_directoryLE->text());
Utils::FilePaths filesWeMayOpen FilePaths filesWeMayOpen = filtered(scanDirectoryForFiles(base), [](const FilePath &f) {
= Utils::filtered(scanDirectoryForFiles(base), [](const Utils::FilePath &f) { return ProjectExplorer::ProjectManager::canOpenProjectForMimeType(mimeTypeForFile(f));
return ProjectExplorer::ProjectManager::canOpenProjectForMimeType(
Utils::mimeTypeForFile(f));
}); });
// limit the files to the most top-level item(s) // limit the files to the most top-level item(s)
int minimum = std::numeric_limits<int>::max(); int minimum = std::numeric_limits<int>::max();
for (const Utils::FilePath &f : filesWeMayOpen) { for (const FilePath &f : filesWeMayOpen) {
int parentCount = f.toString().count('/'); int parentCount = f.toString().count('/');
if (parentCount < minimum) if (parentCount < minimum)
minimum = parentCount; minimum = parentCount;
} }
filesWeMayOpen = Utils::filtered(filesWeMayOpen, [minimum](const Utils::FilePath &f) { filesWeMayOpen = filtered(filesWeMayOpen, [minimum](const FilePath &f) {
return f.toString().count('/') == minimum; return f.toString().count('/') == minimum;
}); });
@@ -219,8 +220,7 @@ void GitLabCloneDialog::cloneFinished(bool success)
"opened. Try importing the project as a generic project.")); "opened. Try importing the project as a generic project."));
accept(); accept();
} else { } else {
const QStringList pFiles = Utils::transform(filesWeMayOpen, const QStringList pFiles = Utils::transform(filesWeMayOpen, [base](const FilePath &f) {
[base](const Utils::FilePath &f) {
return f.relativePath(base).toUserOutput(); return f.relativePath(base).toUserOutput();
}); });
bool ok = false; bool ok = false;
@@ -234,8 +234,7 @@ void GitLabCloneDialog::cloneFinished(bool success)
} }
} else { } else {
m_cloneOutput->appendPlainText(tr("Cloning failed.") + emptyLine); m_cloneOutput->appendPlainText(tr("Cloning failed.") + emptyLine);
const Utils::FilePath fullPath = m_pathChooser->filePath() const FilePath fullPath = m_pathChooser->filePath().pathAppended(m_directoryLE->text());
.pathAppended(m_directoryLE->text());
fullPath.removeRecursively(); fullPath.removeRecursively();
m_cloneButton->setEnabled(true); m_cloneButton->setEnabled(true);
m_cancelButton->setEnabled(true); m_cancelButton->setEnabled(true);

View File

@@ -81,7 +81,7 @@ VcsCommand *VcsBaseClientImpl::createCommand(const FilePath &workingDirectory,
if (editor) // assume that the commands output is the important thing if (editor) // assume that the commands output is the important thing
cmd->addFlags(VcsCommand::SilentOutput); cmd->addFlags(VcsCommand::SilentOutput);
} else if (editor) { } else if (editor) {
connect(cmd, &VcsCommand::finished, editor, connect(cmd, &VcsCommand::done, editor,
[editor, cmd] { editor->setPlainText(cmd->cleanedStdOut()); }); [editor, cmd] { editor->setPlainText(cmd->cleanedStdOut()); });
} }
@@ -412,8 +412,8 @@ void VcsBaseClient::revertFile(const FilePath &workingDir,
// Indicate repository change or file list // Indicate repository change or file list
VcsCommand *cmd = createCommand(workingDir); VcsCommand *cmd = createCommand(workingDir);
const QStringList files = QStringList(workingDir.pathAppended(file).toString()); const QStringList files = QStringList(workingDir.pathAppended(file).toString());
connect(cmd, &VcsCommand::finished, this, [this, files](bool success) { connect(cmd, &VcsCommand::done, this, [this, files, cmd] {
if (success) if (cmd->result() == ProcessResult::FinishedWithSuccess)
emit changed(files); emit changed(files);
}, Qt::QueuedConnection); }, Qt::QueuedConnection);
enqueueJob(cmd, args); enqueueJob(cmd, args);
@@ -428,8 +428,8 @@ void VcsBaseClient::revertAll(const FilePath &workingDir,
// Indicate repository change or file list // Indicate repository change or file list
VcsCommand *cmd = createCommand(workingDir); VcsCommand *cmd = createCommand(workingDir);
const QStringList files = QStringList(workingDir.toString()); const QStringList files = QStringList(workingDir.toString());
connect(cmd, &VcsCommand::finished, this, [this, files](bool success) { connect(cmd, &VcsCommand::done, this, [this, files, cmd] {
if (success) if (cmd->result() == ProcessResult::FinishedWithSuccess)
emit changed(files); emit changed(files);
}, Qt::QueuedConnection); }, Qt::QueuedConnection);
enqueueJob(createCommand(workingDir), args); enqueueJob(createCommand(workingDir), args);
@@ -443,8 +443,7 @@ void VcsBaseClient::status(const FilePath &workingDir,
args << extraOptions << file; args << extraOptions << file;
VcsOutputWindow::setRepository(workingDir); VcsOutputWindow::setRepository(workingDir);
VcsCommand *cmd = createCommand(workingDir, nullptr, VcsWindowOutputBind); VcsCommand *cmd = createCommand(workingDir, nullptr, VcsWindowOutputBind);
connect(cmd, &VcsCommand::finished, connect(cmd, &VcsCommand::done, VcsOutputWindow::instance(), &VcsOutputWindow::clearRepository,
VcsOutputWindow::instance(), &VcsOutputWindow::clearRepository,
Qt::QueuedConnection); Qt::QueuedConnection);
enqueueJob(cmd, args); enqueueJob(cmd, args);
} }
@@ -454,7 +453,7 @@ void VcsBaseClient::emitParsedStatus(const FilePath &repository, const QStringLi
QStringList args(vcsCommandString(StatusCommand)); QStringList args(vcsCommandString(StatusCommand));
args << extraOptions; args << extraOptions;
VcsCommand *cmd = createCommand(repository); VcsCommand *cmd = createCommand(repository);
connect(cmd, &VcsCommand::finished, this, [this, cmd] { statusParser(cmd->cleanedStdOut()); }); connect(cmd, &VcsCommand::done, this, [this, cmd] { statusParser(cmd->cleanedStdOut()); });
enqueueJob(cmd, args); enqueueJob(cmd, args);
} }
@@ -528,8 +527,8 @@ void VcsBaseClient::update(const FilePath &repositoryRoot, const QString &revisi
QStringList args(vcsCommandString(UpdateCommand)); QStringList args(vcsCommandString(UpdateCommand));
args << revisionSpec(revision) << extraOptions; args << revisionSpec(revision) << extraOptions;
VcsCommand *cmd = createCommand(repositoryRoot); VcsCommand *cmd = createCommand(repositoryRoot);
connect(cmd, &VcsCommand::finished, this, [this, repositoryRoot](bool success) { connect(cmd, &VcsCommand::done, this, [this, repositoryRoot, cmd] {
if (success) if (cmd->result() == ProcessResult::FinishedWithSuccess)
emit changed(repositoryRoot.toString()); emit changed(repositoryRoot.toString());
}, Qt::QueuedConnection); }, Qt::QueuedConnection);
enqueueJob(cmd, args); enqueueJob(cmd, args);
@@ -552,7 +551,7 @@ void VcsBaseClient::commit(const FilePath &repositoryRoot,
args << extraOptions << files; args << extraOptions << files;
VcsCommand *cmd = createCommand(repositoryRoot, nullptr, VcsWindowOutputBind); VcsCommand *cmd = createCommand(repositoryRoot, nullptr, VcsWindowOutputBind);
if (!commitMessageFile.isEmpty()) if (!commitMessageFile.isEmpty())
connect(cmd, &VcsCommand::finished, [commitMessageFile] { QFile(commitMessageFile).remove(); }); connect(cmd, &VcsCommand::done, [commitMessageFile] { QFile(commitMessageFile).remove(); });
enqueueJob(cmd, args); enqueueJob(cmd, args);
} }

View File

@@ -148,8 +148,9 @@ void VcsBaseDiffEditorController::runCommand(const QList<QStringList> &args, uns
d->m_command = VcsBaseClient::createVcsCommand(workingDirectory(), d->m_processEnvironment); d->m_command = VcsBaseClient::createVcsCommand(workingDirectory(), d->m_processEnvironment);
d->m_command->setDisplayName(d->m_displayName); d->m_command->setDisplayName(d->m_displayName);
d->m_command->setCodec(codec ? codec : EditorManager::defaultTextCodec()); d->m_command->setCodec(codec ? codec : EditorManager::defaultTextCodec());
connect(d->m_command.data(), &VcsCommand::finished, connect(d->m_command.data(), &VcsCommand::done, this, [this] {
this, [this](bool success) { d->commandFinished(success); }); d->commandFinished(d->m_command->result() == ProcessResult::FinishedWithSuccess);
});
d->m_command->addFlags(flags); d->m_command->addFlags(flags);
for (const QStringList &arg : args) { for (const QStringList &arg : args) {

View File

@@ -1394,7 +1394,9 @@ void VcsBaseEditorWidget::setCommand(VcsCommand *command)
if (command) { if (command) {
d->m_progressIndicator = new ProgressIndicator(ProgressIndicatorSize::Large); d->m_progressIndicator = new ProgressIndicator(ProgressIndicatorSize::Large);
d->m_progressIndicator->attachToWidget(this); d->m_progressIndicator->attachToWidget(this);
connect(command, &VcsCommand::finished, this, &VcsBaseEditorWidget::reportCommandFinished); connect(command, &VcsCommand::done, this, [this] {
reportCommandFinished(d->m_command->result() == ProcessResult::FinishedWithSuccess);
});
QTimer::singleShot(100, this, &VcsBaseEditorWidget::showProgressIndicator); QTimer::singleShot(100, this, &VcsBaseEditorWidget::showProgressIndicator);
} }
} }

View File

@@ -365,7 +365,9 @@ void VcsCommandPage::start(VcsCommand *command)
connect(command, &VcsCommand::stdErrText, this, [this](const QString &text) { connect(command, &VcsCommand::stdErrText, this, [this](const QString &text) {
m_formatter->appendMessage(text, StdErrFormat); m_formatter->appendMessage(text, StdErrFormat);
}); });
connect(command, &VcsCommand::finished, this, &VcsCommandPage::finished); connect(command, &VcsCommand::done, this, [this] {
finished(m_command->result() == ProcessResult::FinishedWithSuccess);
});
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
m_logPlainTextEdit->clear(); m_logPlainTextEdit->clear();
m_overwriteOutput = false; m_overwriteOutput = false;