From f933602c7006cdc4f4909464cfe6db34905f9dbb Mon Sep 17 00:00:00 2001
From: Tobias Hunger <tobias.hunger@nokia.com>
Date: Thu, 7 Jan 2010 19:40:47 +0100
Subject: [PATCH] Fall back to default editors if none is found by Id

 * Fall back to the default editor for a the file's
   mime type when it fails to open by editor id.

   This fixes opening editors in a session with invalid
   ids.

Reviewed-by: dt
---
 src/plugins/coreplugin/editormanager/editormanager.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index 517fce78c4c..945d1424e5c 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -1131,6 +1131,10 @@ IEditor *EditorManager::openEditor(Core::Internal::EditorView *view, const QStri
     }
     QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
     IEditor *editor = createEditor(editorId, fileName);
+    // If we could not open the file in the requested editor, fall
+    // back to the default editor:
+    if (!editor)
+        editor = createEditor(QString(), fileName);
     if (!editor || !editor->open(fileName)) {
         QApplication::restoreOverrideCursor();
         QMessageBox::critical(m_d->m_core->mainWindow(), tr("Opening File"), tr("Cannot open file %1!").arg(QDir::toNativeSeparators(fileName)));
-- 
GitLab