From 1035224774d43b9a4ad2098e8cfa0b8b9c36fd30 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 18 Sep 2012 08:45:43 +0200 Subject: [PATCH] Editor: Fix: "Open File With..." with empty File and no extension is now handled as a plain text file. Task-number: QTCREATORBUG-7591 Change-Id: I21471315cb6144f27c374e0919fd16e62f7d8f2a Reviewed-by: Christian Stenger --- src/plugins/bineditor/bineditorplugin.cpp | 4 +++- src/plugins/coreplugin/editormanager/editormanager.cpp | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index c67c19574f9..7b5d5f8a743 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -222,8 +222,10 @@ public: bool open(QString *errorString, const QString &fileName, quint64 offset = 0) { QFile file(fileName); - if (offset >= static_cast(file.size())) + if (offset >= static_cast(file.size())) { + *errorString = tr("The Binary Editor can not open empty files."); return false; + } if (file.open(QIODevice::ReadOnly)) { file.close(); m_fileName = fileName; diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index cb190886973..2ebef075a65 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -1173,9 +1173,10 @@ Core::Id EditorManager::getOpenWithEditorId(const QString &fileName, bool *isExternalEditor) const { // Collect editors that can open the file - const MimeType mt = ICore::mimeDatabase()->findByFile(fileName); + MimeType mt = ICore::mimeDatabase()->findByFile(fileName); + //Unable to determine mime type of fileName. Falling back to text/plain", if (!mt) - return Id(); + mt = ICore::mimeDatabase()->findByType(QLatin1String("text/plain")); QStringList allEditorIds; QStringList allEditorDisplayNames; QList externalEditorIds;