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

@@ -1211,15 +1211,6 @@ DiffChunk VcsBaseEditorWidget::diffChunk(QTextCursor cursor) const
return rc;
}
void VcsBaseEditorWidget::reportCommandFinished(bool success)
{
hideProgressIndicator();
if (!success)
textDocument()->setPlainText(tr("Failed to retrieve data."));
else if (d->m_defaultLineNumber >= 0)
gotoLine(d->m_defaultLineNumber);
}
const VcsBaseEditorParameters *VcsBaseEditor::findType(const VcsBaseEditorParameters *array,
int arraySize,
EditorContentType et)
@@ -1394,9 +1385,7 @@ void VcsBaseEditorWidget::setCommand(VcsCommand *command)
if (command) {
d->m_progressIndicator = new ProgressIndicator(ProgressIndicatorSize::Large);
d->m_progressIndicator->attachToWidget(this);
connect(command, &VcsCommand::done, this, [this] {
reportCommandFinished(d->m_command->result() == ProcessResult::FinishedWithSuccess);
});
connect(command, &VcsCommand::done, this, &VcsBaseEditorWidget::hideProgressIndicator);
QTimer::singleShot(100, this, &VcsBaseEditorWidget::showProgressIndicator);
}
}
@@ -1406,6 +1395,12 @@ void VcsBaseEditorWidget::setDefaultLineNumber(int line)
d->m_defaultLineNumber = line;
}
void VcsBaseEditorWidget::gotoDefaultLine()
{
if (d->m_defaultLineNumber >= 0)
gotoLine(d->m_defaultLineNumber);
}
void VcsBaseEditorWidget::setPlainText(const QString &text)
{
textDocument()->setPlainText(text);