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 <christian.stenger@digia.com>
This commit is contained in:
David Schulz
2012-09-18 08:45:43 +02:00
committed by David Schulz
parent 61fb4f55c8
commit 1035224774
2 changed files with 6 additions and 3 deletions

View File

@@ -222,8 +222,10 @@ public:
bool open(QString *errorString, const QString &fileName, quint64 offset = 0) {
QFile file(fileName);
if (offset >= static_cast<quint64>(file.size()))
if (offset >= static_cast<quint64>(file.size())) {
*errorString = tr("The Binary Editor can not open empty files.");
return false;
}
if (file.open(QIODevice::ReadOnly)) {
file.close();
m_fileName = fileName;

View File

@@ -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<Id> externalEditorIds;