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
This commit is contained in:
Tobias Hunger
2010-01-07 19:40:47 +01:00
parent 9c845a2a52
commit f933602c70

View File

@@ -1131,6 +1131,10 @@ IEditor *EditorManager::openEditor(Core::Internal::EditorView *view, const QStri
} }
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
IEditor *editor = createEditor(editorId, fileName); 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)) { if (!editor || !editor->open(fileName)) {
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
QMessageBox::critical(m_d->m_core->mainWindow(), tr("Opening File"), tr("Cannot open file %1!").arg(QDir::toNativeSeparators(fileName))); QMessageBox::critical(m_d->m_core->mainWindow(), tr("Opening File"), tr("Cannot open file %1!").arg(QDir::toNativeSeparators(fileName)));