VcsBaseClient: Fix going to default line number

Since we are being connected to the same done() signal twice,
the order of slot invocations started to play a role.
We were connecting done() signal to
VcsBaseEditorWidget::reportCommandFinished() first
and to VcsBaseEditorWidget::setPlainText() afterwards,
so they were executed exactly in this order. However, this
order isn't desired, as we need to set text first and
jump to line afterwards.

In order to fix it so that we don't rely on connection
order we handle setting the content and jumping into
the default line in one common handler.

Amends c767f193ce

Change-Id: Iea17476cc25b54759457710ecb6b6de2f0f5caf7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Jarek Kobus
2022-09-21 15:42:02 +02:00
parent 1dbdc46ea1
commit 5eae4d5279
3 changed files with 18 additions and 17 deletions

View File

@@ -15,6 +15,8 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/idocument.h>
#include <texteditor/textdocument.h>
#include <utils/commandline.h>
#include <utils/environment.h>
#include <utils/qtcassert.h>
@@ -81,8 +83,14 @@ 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::done, editor,
[editor, cmd] { editor->setPlainText(cmd->cleanedStdOut()); });
connect(cmd, &VcsCommand::done, editor, [editor, cmd] {
if (cmd->result() != ProcessResult::FinishedWithSuccess) {
editor->textDocument()->setPlainText(tr("Failed to retrieve data."));
return;
}
editor->setPlainText(cmd->cleanedStdOut());
editor->gotoDefaultLine();
});
}
return cmd;