forked from qt-creator/qt-creator
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 <qt_sanity_bot@ovi.com> Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
@@ -205,9 +205,9 @@ StateListener::StateListener(QObject *parent) :
|
|||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
Core::ICore *core = Core::ICore::instance();
|
Core::ICore *core = Core::ICore::instance();
|
||||||
connect(core->fileManager(), SIGNAL(currentFileChanged(QString)),
|
connect(core->editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)),
|
||||||
this, SLOT(slotStateChanged()));
|
this, SLOT(slotStateChanged()));
|
||||||
connect(core->editorManager()->instance(), SIGNAL(currentEditorStateChanged(Core::IEditor*)),
|
connect(core->editorManager(), SIGNAL(currentEditorStateChanged(Core::IEditor*)),
|
||||||
this, SLOT(slotStateChanged()));
|
this, SLOT(slotStateChanged()));
|
||||||
connect(core->vcsManager(), SIGNAL(repositoryChanged(QString)),
|
connect(core->vcsManager(), SIGNAL(repositoryChanged(QString)),
|
||||||
this, SLOT(slotStateChanged()));
|
this, SLOT(slotStateChanged()));
|
||||||
@@ -235,7 +235,11 @@ void StateListener::slotStateChanged()
|
|||||||
// temporary path prefix or does the file contains a hash, indicating a project
|
// temporary path prefix or does the file contains a hash, indicating a project
|
||||||
// folder?
|
// folder?
|
||||||
State state;
|
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.
|
QScopedPointer<QFileInfo> currentFileInfo; // Instantiate QFileInfo only once if required.
|
||||||
if (!state.currentFile.isEmpty()) {
|
if (!state.currentFile.isEmpty()) {
|
||||||
const bool isTempFile = state.currentFile.startsWith(QDir::tempPath());
|
const bool isTempFile = state.currentFile.startsWith(QDir::tempPath());
|
||||||
|
|||||||
Reference in New Issue
Block a user