From 706d78b58d6744bcc59b577e92ab027479a83783 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 3 Mar 2015 08:17:21 +0100 Subject: [PATCH] BinEditor: Complain about missing file, not empty size When trying to open a non-existing file with the binary editor, it would complain that it couldn't empty files, instead of complaining that the file does not exist. Change-Id: I50fc8afb8c59cad211ee68356020a81891708097 Task-number: QTCREATORBUG-14078 Reviewed-by: Christian Stenger --- src/plugins/bineditor/bineditorplugin.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index a47ddf9e921..586bb58e52b 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -267,19 +267,19 @@ public: bool open(QString *errorString, const QString &fileName, quint64 offset = 0) { QFile file(fileName); - quint64 size = static_cast(file.size()); - if (size == 0 && !fileName.isEmpty()) { - QString msg = tr("The Binary Editor cannot open empty files."); - if (errorString) - *errorString = msg; - else - QMessageBox::critical(ICore::mainWindow(), tr("File Error"), msg); - return false; - } - if (offset >= size) - return false; if (file.open(QIODevice::ReadOnly)) { file.close(); + quint64 size = static_cast(file.size()); + if (size == 0) { + QString msg = tr("The Binary Editor cannot open empty files."); + if (errorString) + *errorString = msg; + else + QMessageBox::critical(ICore::mainWindow(), tr("File Error"), msg); + return false; + } + if (offset >= size) + return false; setFilePath(FileName::fromString(fileName)); m_widget->setSizes(offset, file.size()); return true;