From 003e25d488ef8b4ac9b797cc26c667b84f246f09 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Sun, 29 Sep 2013 22:57:21 +0300 Subject: 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 --- src/plugins/vcsbase/vcsbaseclient.cpp | 1 + src/plugins/vcsbase/vcsbaseeditor.cpp | 9 +++++++++ src/plugins/vcsbase/vcsbaseeditor.h | 2 ++ 3 files changed, 12 insertions(+) (limited to 'src/plugins/vcsbase') diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp index 1d83c0ef8b..feb4c5588b 100644 --- a/src/plugins/vcsbase/vcsbaseclient.cpp +++ b/src/plugins/vcsbase/vcsbaseclient.cpp @@ -143,6 +143,7 @@ void VcsBaseClientPrivate::saveSettings() void VcsBaseClientPrivate::bindCommandToEditor(Command *cmd, VcsBaseEditorWidget *editor) { + editor->setCommand(cmd); QObject::connect(cmd, SIGNAL(finished(bool,int,QVariant)), m_cmdFinishedMapper, SLOT(map())); m_cmdFinishedMapper->setMapping(cmd, editor); } diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index 9141a4b620..0c415cf8eb 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -32,6 +32,7 @@ #include "baseannotationhighlighter.h" #include "vcsbaseplugin.h" #include "vcsbaseeditorparameterwidget.h" +#include "command.h" #include #include @@ -575,6 +576,7 @@ public: VcsBaseEditorParameterWidget *m_configurationWidget; bool m_mouseDragging; QList m_textCursorHandlers; + QPointer m_command; private: QComboBox *m_entriesComboBox; @@ -1350,6 +1352,13 @@ VcsBaseEditorParameterWidget *VcsBaseEditorWidget::configurationWidget() const 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. QString VcsBaseEditorWidget::findDiffFile(const QString &f) const { diff --git a/src/plugins/vcsbase/vcsbaseeditor.h b/src/plugins/vcsbase/vcsbaseeditor.h index b2fd845d9e..ae2587c88a 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.h +++ b/src/plugins/vcsbase/vcsbaseeditor.h @@ -55,6 +55,7 @@ class VcsBaseEditorWidgetPrivate; class DiffHighlighter; class BaseAnnotationHighlighter; class VcsBaseEditorParameterWidget; +class Command; // Documentation inside enum EditorContentType @@ -188,6 +189,7 @@ public: bool setConfigurationWidget(VcsBaseEditorParameterWidget *w); VcsBaseEditorParameterWidget *configurationWidget() const; + void setCommand(Command *command); /* 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 * the editor, they get a 'tag' containing type and parameters (dynamic property string). */ -- cgit v1.2.1