diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp index c21ea9ae221..970225765f7 100644 --- a/src/plugins/vcsbase/vcsbaseclient.cpp +++ b/src/plugins/vcsbase/vcsbaseclient.cpp @@ -51,17 +51,6 @@ #include #include -static void commandFinished(VcsBase::VcsBaseEditorWidget *editor, VcsBase::VcsCommand *cmd) -{ - if (!cmd->lastExecutionSuccess()) { - editor->reportCommandFinished(false, cmd->lastExecutionExitCode(), cmd->cookie()); - } else if (cmd->cookie().type() == QVariant::Int) { - const int line = cmd->cookie().toInt(); - if (line >= 0) - editor->gotoLine(line); - } -} - /*! \class VcsBase::VcsBaseClient @@ -131,12 +120,8 @@ VcsCommand *VcsBaseClientImpl::createCommand(const QString &workingDirectory, { auto cmd = new VcsCommand(workingDirectory, processEnvironment()); cmd->setDefaultTimeoutS(vcsTimeoutS()); - if (editor) { + if (editor) editor->setCommand(cmd); - connect(editor, &QObject::destroyed, cmd, &VcsCommand::abort); - connect(cmd, &VcsCommand::finished, - editor, [editor, cmd]() { commandFinished(editor, cmd); }); - } if (mode == VcsWindowOutputBind) { cmd->addFlags(VcsCommand::ShowStdOut); if (editor) // assume that the commands output is the important thing diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index 5ffee0cf910..4c333e6b229 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -1199,10 +1199,15 @@ DiffChunk VcsBaseEditorWidget::diffChunk(QTextCursor cursor) const void VcsBaseEditorWidget::reportCommandFinished(bool ok, int exitCode, const QVariant &data) { Q_UNUSED(exitCode); - Q_UNUSED(data); - if (!ok) + hideProgressIndicator(); + if (!ok) { textDocument()->setPlainText(tr("Failed to retrieve data.")); + } else if (data.type() == QVariant::Int) { + const int line = data.toInt(); + if (line >= 0) + gotoLine(line); + } } const VcsBaseEditorParameters *VcsBaseEditor::findType(const VcsBaseEditorParameters *array, @@ -1385,11 +1390,10 @@ void VcsBaseEditorWidget::setCommand(VcsCommand *command) hideProgressIndicator(); } d->m_command = command; - if (d->m_command) { + if (command) { d->m_progressIndicator = new Utils::ProgressIndicator(Utils::ProgressIndicator::Large); d->m_progressIndicator->attachToWidget(this); - connect(d->m_command.data(), &VcsCommand::finished, - this, &VcsBaseEditorWidget::hideProgressIndicator); + connect(command, &VcsCommand::finished, this, &VcsBaseEditorWidget::reportCommandFinished); QTimer::singleShot(100, this, &VcsBaseEditorWidget::showProgressIndicator); } }