forked from qt-creator/qt-creator
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 <daniel.teske@digia.com> Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
@@ -216,8 +216,6 @@ DocumentManager::DocumentManager(QObject *parent)
|
||||
{
|
||||
d = new DocumentManagerPrivate;
|
||||
m_instance = this;
|
||||
connect(ICore::instance(), SIGNAL(contextChanged(QList<Core::IContext*>,Core::Context)),
|
||||
this, SLOT(syncWithEditor(QList<Core::IContext*>)));
|
||||
qApp->installEventFilter(this);
|
||||
|
||||
readSettings();
|
||||
@@ -1129,22 +1127,6 @@ void DocumentManager::checkForReload()
|
||||
// dump();
|
||||
}
|
||||
|
||||
void DocumentManager::syncWithEditor(const QList<Core::IContext *> &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.
|
||||
|
@@ -163,7 +163,6 @@ private slots:
|
||||
void checkForNewFileName();
|
||||
void checkForReload();
|
||||
void changedFile(const QString &file);
|
||||
void syncWithEditor(const QList<Core::IContext *> &context);
|
||||
|
||||
private:
|
||||
explicit DocumentManager(QObject *parent);
|
||||
|
@@ -526,6 +526,8 @@ void EditorManager::handleContextChange(const QList<Core::IContext *> &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)
|
||||
|
Reference in New Issue
Block a user