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

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

View File

@@ -1394,7 +1394,9 @@ void VcsBaseEditorWidget::setCommand(VcsCommand *command)
if (command) {
d->m_progressIndicator = new ProgressIndicator(ProgressIndicatorSize::Large);
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);
}
}

View File

@@ -365,7 +365,9 @@ void VcsCommandPage::start(VcsCommand *command)
connect(command, &VcsCommand::stdErrText, this, [this](const QString &text) {
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);
m_logPlainTextEdit->clear();
m_overwriteOutput = false;