aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/vcsbase/vcsbaseplugin.cpp
diff options
context:
space:
mode:
authorTobias Hunger <[email protected]>2011-10-06 19:36:26 +0200
committerTobias Hunger <[email protected]>2011-10-10 15:39:50 +0200
commitbdf486fca1b294d6725e6fd580d7fb6b95aa7fbb (patch)
tree7ed917b22eed14e1a32396a2bac72d4d7788c4fc /src/plugins/vcsbase/vcsbaseplugin.cpp
parentd6fcc1d6c4bf9fb1884eb2408f153f0716b689bf (diff)
VCS: Get current file from the editor
Get the current file from the editor, not the filemanager. The later does not get updated for temporary files like those created by git blame, leaving the file-based actions in the VCSes enabled when viewing those temporary files, triggering actions on the last real file that was visible. Task-number: QTCREATORBUG-6250 Change-Id: I5c2d3c62805f69bc8e103f0776cd6796332f606c Reviewed-on: http://codereview.qt-project.org/6175 Sanity-Review: Qt Sanity Bot <[email protected]> Reviewed-by: Daniel Teske <[email protected]>
Diffstat (limited to 'src/plugins/vcsbase/vcsbaseplugin.cpp')
-rw-r--r--src/plugins/vcsbase/vcsbaseplugin.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/plugins/vcsbase/vcsbaseplugin.cpp b/src/plugins/vcsbase/vcsbaseplugin.cpp
index d011686bf9f..337c1418970 100644
--- a/src/plugins/vcsbase/vcsbaseplugin.cpp
+++ b/src/plugins/vcsbase/vcsbaseplugin.cpp
@@ -205,9 +205,9 @@ StateListener::StateListener(QObject *parent) :
QObject(parent)
{
Core::ICore *core = Core::ICore::instance();
- connect(core->fileManager(), SIGNAL(currentFileChanged(QString)),
+ connect(core->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)),
this, SLOT(slotStateChanged()));
- connect(core->editorManager()->instance(), SIGNAL(currentEditorStateChanged(Core::IEditor*)),
+ connect(core->editorManager(), SIGNAL(currentEditorStateChanged(Core::IEditor*)),
this, SLOT(slotStateChanged()));
connect(core->vcsManager(), SIGNAL(repositoryChanged(QString)),
this, SLOT(slotStateChanged()));
@@ -235,7 +235,11 @@ void StateListener::slotStateChanged()
// temporary path prefix or does the file contains a hash, indicating a project
// folder?
State state;
- state.currentFile = core->fileManager()->currentFile();
+ Core::EditorManager *em = core->editorManager();
+ if (!em || !em->currentEditor() || !em->currentEditor()->file())
+ state.currentFile.clear();
+ else
+ state.currentFile = em->currentEditor()->file()->fileName();
QScopedPointer<QFileInfo> currentFileInfo; // Instantiate QFileInfo only once if required.
if (!state.currentFile.isEmpty()) {
const bool isTempFile = state.currentFile.startsWith(QDir::tempPath());