VCS: Abort previous command for the same editor

It is very common to have output from a previous (longer) command appear
instead of the newly created one.

For example: Open a log. Check "Show Diff" and immediately uncheck it.
If this is done fast enough (or with a high Log Count limit) the output
with the diff will appear instead of the normal log.

Change-Id: Ie64cc4a383a261f5328a4d0486eec93f73766679
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Orgad Shaneh
2013-09-29 22:57:21 +03:00
committed by Orgad Shaneh
parent 8e90640edb
commit 003e25d488
4 changed files with 17 additions and 2 deletions

View File

@@ -2467,8 +2467,11 @@ VcsBase::Command *GitClient::createCommand(const QString &workingDirectory,
VcsBase::Command *command = new VcsBase::Command(gitBinaryPath(), workingDirectory, processEnvironment()); VcsBase::Command *command = new VcsBase::Command(gitBinaryPath(), workingDirectory, processEnvironment());
command->setCodec(getSourceCodec(currentDocumentPath())); command->setCodec(getSourceCodec(currentDocumentPath()));
command->setCookie(QVariant(editorLineNumber)); command->setCookie(QVariant(editorLineNumber));
if (editor) if (editor) {
connect(command, SIGNAL(finished(bool,int,QVariant)), editor, SLOT(commandFinishedGotoLine(bool,int,QVariant))); editor->setCommand(command);
connect(command, SIGNAL(finished(bool,int,QVariant)),
editor, SLOT(commandFinishedGotoLine(bool,int,QVariant)));
}
if (useOutputToWindow) { if (useOutputToWindow) {
command->addFlags(VcsBasePlugin::ShowStdOutInLogWindow); command->addFlags(VcsBasePlugin::ShowStdOutInLogWindow);
command->addFlags(VcsBasePlugin::ShowSuccessMessage); command->addFlags(VcsBasePlugin::ShowSuccessMessage);

View File

@@ -143,6 +143,7 @@ void VcsBaseClientPrivate::saveSettings()
void VcsBaseClientPrivate::bindCommandToEditor(Command *cmd, VcsBaseEditorWidget *editor) void VcsBaseClientPrivate::bindCommandToEditor(Command *cmd, VcsBaseEditorWidget *editor)
{ {
editor->setCommand(cmd);
QObject::connect(cmd, SIGNAL(finished(bool,int,QVariant)), m_cmdFinishedMapper, SLOT(map())); QObject::connect(cmd, SIGNAL(finished(bool,int,QVariant)), m_cmdFinishedMapper, SLOT(map()));
m_cmdFinishedMapper->setMapping(cmd, editor); m_cmdFinishedMapper->setMapping(cmd, editor);
} }

View File

@@ -32,6 +32,7 @@
#include "baseannotationhighlighter.h" #include "baseannotationhighlighter.h"
#include "vcsbaseplugin.h" #include "vcsbaseplugin.h"
#include "vcsbaseeditorparameterwidget.h" #include "vcsbaseeditorparameterwidget.h"
#include "command.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/vcsmanager.h> #include <coreplugin/vcsmanager.h>
@@ -575,6 +576,7 @@ public:
VcsBaseEditorParameterWidget *m_configurationWidget; VcsBaseEditorParameterWidget *m_configurationWidget;
bool m_mouseDragging; bool m_mouseDragging;
QList<AbstractTextCursorHandler *> m_textCursorHandlers; QList<AbstractTextCursorHandler *> m_textCursorHandlers;
QPointer<Command> m_command;
private: private:
QComboBox *m_entriesComboBox; QComboBox *m_entriesComboBox;
@@ -1350,6 +1352,13 @@ VcsBaseEditorParameterWidget *VcsBaseEditorWidget::configurationWidget() const
return d->m_configurationWidget; return d->m_configurationWidget;
} }
void VcsBaseEditorWidget::setCommand(Command *command)
{
if (d->m_command)
d->m_command->abort();
d->m_command = command;
}
// Find the complete file from a diff relative specification. // Find the complete file from a diff relative specification.
QString VcsBaseEditorWidget::findDiffFile(const QString &f) const QString VcsBaseEditorWidget::findDiffFile(const QString &f) const
{ {

View File

@@ -55,6 +55,7 @@ class VcsBaseEditorWidgetPrivate;
class DiffHighlighter; class DiffHighlighter;
class BaseAnnotationHighlighter; class BaseAnnotationHighlighter;
class VcsBaseEditorParameterWidget; class VcsBaseEditorParameterWidget;
class Command;
// Documentation inside // Documentation inside
enum EditorContentType enum EditorContentType
@@ -188,6 +189,7 @@ public:
bool setConfigurationWidget(VcsBaseEditorParameterWidget *w); bool setConfigurationWidget(VcsBaseEditorParameterWidget *w);
VcsBaseEditorParameterWidget *configurationWidget() const; VcsBaseEditorParameterWidget *configurationWidget() const;
void setCommand(Command *command);
/* Tagging editors: Sometimes, an editor should be re-used, for example, when showing /* Tagging editors: Sometimes, an editor should be re-used, for example, when showing
* a diff of the same file with different diff-options. In order to be able to find * a diff of the same file with different diff-options. In order to be able to find
* the editor, they get a 'tag' containing type and parameters (dynamic property string). */ * the editor, they get a 'tag' containing type and parameters (dynamic property string). */