From 324de13b4e6703db778010d0682ac26cff359516 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 14 Feb 2018 12:34:14 +0100 Subject: [PATCH] Fix ordering of items in open documents popup When the document history was updated, it was cleaned of any items which no longer had a document open for them. This worked fine when that only happened when user closed documents. Nowadays this also happens when suspending documents without user interaction. Only remove items from the document history if they are no longer available even as a suspended document. Task-number: QTCREATORBUG-19758 Change-Id: I131a24823b5c456879b67a35b039768a15bd7716 Reviewed-by: Konstantin Tokarev Reviewed-by: David Schulz --- src/plugins/coreplugin/editormanager/documentmodel.cpp | 5 +++++ src/plugins/coreplugin/editormanager/documentmodel.h | 1 + src/plugins/coreplugin/editormanager/editorview.cpp | 7 +++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/documentmodel.cpp b/src/plugins/coreplugin/editormanager/documentmodel.cpp index 7aa24d4c852..fae56815ca0 100644 --- a/src/plugins/coreplugin/editormanager/documentmodel.cpp +++ b/src/plugins/coreplugin/editormanager/documentmodel.cpp @@ -517,6 +517,11 @@ Utils::optional DocumentModel::indexOfDocument(IDocument *document) return d->indexOfDocument(document); } +Utils::optional DocumentModel::indexOfFilePath(const Utils::FileName &filePath) +{ + return d->indexOfFilePath(filePath); +} + DocumentModel::Entry *DocumentModel::entryForDocument(IDocument *document) { return Utils::findOrDefault(d->m_entries, diff --git a/src/plugins/coreplugin/editormanager/documentmodel.h b/src/plugins/coreplugin/editormanager/documentmodel.h index 73e75f71caf..09bb4652725 100644 --- a/src/plugins/coreplugin/editormanager/documentmodel.h +++ b/src/plugins/coreplugin/editormanager/documentmodel.h @@ -69,6 +69,7 @@ public: static int entryCount(); static QList entries(); static Utils::optional indexOfDocument(IDocument *document); + static Utils::optional indexOfFilePath(const Utils::FileName &filePath); static Entry *entryForDocument(IDocument *document); static Entry *entryForFilePath(const Utils::FileName &filePath); static QList openedDocuments(); diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp index b46c71f7729..4d6dc676232 100644 --- a/src/plugins/coreplugin/editormanager/editorview.cpp +++ b/src/plugins/coreplugin/editormanager/editorview.cpp @@ -268,11 +268,10 @@ void EditorView::updateEditorHistory(IEditor *editor, QList &histo location.state = QVariant(state); for (int i = 0; i < history.size(); ++i) { - if (history.at(i).document == 0 - || history.at(i).document == document - ){ + const EditLocation &item = history.at(i); + if (item.document == document + || !DocumentModel::indexOfFilePath(FileName::fromString(item.fileName))) { history.removeAt(i--); - continue; } } history.prepend(location);