From 2d3a7d432b72dc1bda2eaa0f1591ba5cbb13262c Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Thu, 23 May 2013 14:38:15 +0200 Subject: [PATCH] Avoid having current editor that is not in a view. Was triggering soft assert when opening a session with multiple files open, and then closing the first one. Change-Id: I23a503904222b0126dc36d8b2dcc64021393b45c Reviewed-by: Friedemann Kleint Reviewed-by: Eike Ziller --- src/plugins/coreplugin/editormanager/editormanager.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index b9c586643e8..88762f1f298 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -1028,6 +1028,11 @@ bool EditorManager::closeEditors(const QList &editorsToClose, bool ask if (EditorView *view = viewForEditor(editor)) { if (editor == view->currentEditor()) closedViews += view; + if (d->m_currentEditor == editor) { + // avoid having a current editor without view + setCurrentView(view); + setCurrentEditor(0); + } view->removeEditor(editor); } } @@ -1494,9 +1499,7 @@ IEditor *EditorManager::openEditor(Core::Internal::EditorView *view, const QStri // back to the default editor: if (!editor) editor = createEditor(Id(), fn); - if (!editor) // Internal error - return 0; - + QTC_ASSERT(editor, return 0); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QString errorString; if (!editor->open(&errorString, fn, realFn)) {