Commit 98f679d7 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen
Browse files

purge files which cannot be opened from the "open" editors model

Task-number: QTCREATORBUG-2424
parent 3c552e13
...@@ -939,7 +939,8 @@ void EditorManager::activateEditorForIndex(Internal::EditorView *view, const QMo ...@@ -939,7 +939,8 @@ void EditorManager::activateEditorForIndex(Internal::EditorView *view, const QMo
QString fileName = index.data(Qt::UserRole + 1).toString(); QString fileName = index.data(Qt::UserRole + 1).toString();
QString id = index.data(Qt::UserRole + 2).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) Core::IEditor *EditorManager::placeEditor(Core::Internal::EditorView *view, Core::IEditor *editor)
......
...@@ -204,6 +204,11 @@ void OpenEditorsModel::removeEditor(const QModelIndex &index) ...@@ -204,6 +204,11 @@ void OpenEditorsModel::removeEditor(const QModelIndex &index)
removeEditor(index.row()); removeEditor(index.row());
} }
void OpenEditorsModel::removeEditor(const QString &fileName)
{
removeEditor(findFileName(fileName));
}
void OpenEditorsModel::removeEditor(int idx) void OpenEditorsModel::removeEditor(int idx)
{ {
if (idx < 0) if (idx < 0)
......
...@@ -82,6 +82,7 @@ public: ...@@ -82,6 +82,7 @@ public:
void removeEditor(IEditor *editor); void removeEditor(IEditor *editor);
void removeEditor(const QModelIndex &index); void removeEditor(const QModelIndex &index);
void removeEditor(const QString &fileName);
void removeAllRestoredEditors(); void removeAllRestoredEditors();
void emitDataChanged(IEditor *editor); void emitDataChanged(IEditor *editor);
......
...@@ -282,8 +282,12 @@ void OpenEditorsWindow::selectEditor(QTreeWidgetItem *item) ...@@ -282,8 +282,12 @@ void OpenEditorsWindow::selectEditor(QTreeWidgetItem *item)
EditorView *view = item->data(0, Qt::UserRole+1).value<EditorView*>(); EditorView *view = item->data(0, Qt::UserRole+1).value<EditorView*>();
EditorManager::instance()->activateEditorForFile(view, file, Core::EditorManager::ModeSwitch); EditorManager::instance()->activateEditorForFile(view, file, Core::EditorManager::ModeSwitch);
} else { } else {
EditorManager::instance()->openEditor(item->toolTip(0), item->data(0, Qt::UserRole+2).toByteArray(), if (!EditorManager::instance()->openEditor(
Core::EditorManager::ModeSwitch); item->toolTip(0), item->data(0, Qt::UserRole+2).toByteArray(),
Core::EditorManager::ModeSwitch)) {
EditorManager::instance()->openedEditorsModel()->removeEditor(item->toolTip(0));
delete item;
}
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment