From 98f679d7e5f6a8c0b9aed6cde81ea4d009a25bac Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Date: Thu, 12 May 2011 19:59:54 +0200 Subject: [PATCH] purge files which cannot be opened from the "open" editors model Task-number: QTCREATORBUG-2424 --- src/plugins/coreplugin/editormanager/editormanager.cpp | 3 ++- src/plugins/coreplugin/editormanager/openeditorsmodel.cpp | 5 +++++ src/plugins/coreplugin/editormanager/openeditorsmodel.h | 1 + .../coreplugin/editormanager/openeditorswindow.cpp | 8 ++++++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index d53b3b5be14..5d9cb25c06f 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -939,7 +939,8 @@ void EditorManager::activateEditorForIndex(Internal::EditorView *view, const QMo QString fileName = index.data(Qt::UserRole + 1).toString(); QString id = index.data(Qt::UserRole + 2).toString(); - openEditor(view, fileName, id, flags); + if (!openEditor(view, fileName, id, flags)) + m_d->m_editorModel->removeEditor(index); } Core::IEditor *EditorManager::placeEditor(Core::Internal::EditorView *view, Core::IEditor *editor) diff --git a/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp b/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp index d205e3d8b3b..84f88a424e0 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp @@ -204,6 +204,11 @@ void OpenEditorsModel::removeEditor(const QModelIndex &index) removeEditor(index.row()); } +void OpenEditorsModel::removeEditor(const QString &fileName) +{ + removeEditor(findFileName(fileName)); +} + void OpenEditorsModel::removeEditor(int idx) { if (idx < 0) diff --git a/src/plugins/coreplugin/editormanager/openeditorsmodel.h b/src/plugins/coreplugin/editormanager/openeditorsmodel.h index ab9b14b5ea1..39ee81fb751 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsmodel.h +++ b/src/plugins/coreplugin/editormanager/openeditorsmodel.h @@ -82,6 +82,7 @@ public: void removeEditor(IEditor *editor); void removeEditor(const QModelIndex &index); + void removeEditor(const QString &fileName); void removeAllRestoredEditors(); void emitDataChanged(IEditor *editor); diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp index 98a6d3172a7..8a24d720225 100644 --- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp @@ -282,8 +282,12 @@ void OpenEditorsWindow::selectEditor(QTreeWidgetItem *item) EditorView *view = item->data(0, Qt::UserRole+1).value<EditorView*>(); EditorManager::instance()->activateEditorForFile(view, file, Core::EditorManager::ModeSwitch); } else { - EditorManager::instance()->openEditor(item->toolTip(0), item->data(0, Qt::UserRole+2).toByteArray(), - Core::EditorManager::ModeSwitch); + if (!EditorManager::instance()->openEditor( + item->toolTip(0), item->data(0, Qt::UserRole+2).toByteArray(), + Core::EditorManager::ModeSwitch)) { + EditorManager::instance()->openedEditorsModel()->removeEditor(item->toolTip(0)); + delete item; + } } } -- GitLab