From 6c473db09772c4626e046fd692f53d55ecb275da Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 3 Jun 2014 15:06:16 +0200 Subject: Fix setting DocumentManager::currentFile when clicking into split This broke when introducing delayed setting of the currentEditor when the context changes. Simply move the logic from the document manager to the editor manager, where it arguably belongs to anyway, and also set the currentFile delayed in that case. Task-number: QTCREATORBUG-12264 Change-Id: I67ee3f9a02e62cfa67671629c956a4290361cba8 Reviewed-by: Daniel Teske Reviewed-by: David Schulz --- src/plugins/coreplugin/documentmanager.cpp | 18 ------------------ src/plugins/coreplugin/documentmanager.h | 1 - src/plugins/coreplugin/editormanager/editormanager.cpp | 5 +++++ 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp index 7e68576cc1..384e9f4070 100644 --- a/src/plugins/coreplugin/documentmanager.cpp +++ b/src/plugins/coreplugin/documentmanager.cpp @@ -216,8 +216,6 @@ DocumentManager::DocumentManager(QObject *parent) { d = new DocumentManagerPrivate; m_instance = this; - connect(ICore::instance(), SIGNAL(contextChanged(QList,Core::Context)), - this, SLOT(syncWithEditor(QList))); qApp->installEventFilter(this); readSettings(); @@ -1129,22 +1127,6 @@ void DocumentManager::checkForReload() // dump(); } -void DocumentManager::syncWithEditor(const QList &context) -{ - if (context.isEmpty()) - return; - - Core::IEditor *editor = Core::EditorManager::currentEditor(); - if (!editor || editor->document()->isTemporary()) - return; - foreach (IContext *c, context) { - if (editor->widget() == c->widget()) { - setCurrentFile(editor->document()->filePath()); - break; - } - } -} - /*! Adds the \a fileName to the list of recent files. Associates the file to be reopened with the editor that has the specified \a editorId, if possible. diff --git a/src/plugins/coreplugin/documentmanager.h b/src/plugins/coreplugin/documentmanager.h index 1144a15d29..8fe47ba508 100644 --- a/src/plugins/coreplugin/documentmanager.h +++ b/src/plugins/coreplugin/documentmanager.h @@ -163,7 +163,6 @@ private slots: void checkForNewFileName(); void checkForReload(); void changedFile(const QString &file); - void syncWithEditor(const QList &context); private: explicit DocumentManager(QObject *parent); diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 3b130c5120..172f98f3cc 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -526,6 +526,8 @@ void EditorManager::handleContextChange(const QList &context) d->m_scheduledCurrentEditor = editor; QTimer::singleShot(0, m_instance, SLOT(setCurrentEditorFromContextChange())); } else { + if (editor && !editor->document()->isTemporary()) + DocumentManager::setCurrentFile(editor->document()->filePath()); updateActions(); } } @@ -1027,6 +1029,9 @@ void EditorManager::setCurrentEditorFromContextChange() IEditor *newCurrent = d->m_scheduledCurrentEditor; d->m_scheduledCurrentEditor = 0; setCurrentEditor(newCurrent); + if (!newCurrent->document()->isTemporary()) + DocumentManager::setCurrentFile(newCurrent->document()->filePath()); + } void EditorManager::closeEditor(Core::IEditor *editor, bool askAboutModifiedEditors) -- cgit v1.2.1