Commit 706d78b5 authored by Eike Ziller's avatar Eike Ziller
Browse files

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: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 9abfd712
...@@ -267,8 +267,10 @@ public: ...@@ -267,8 +267,10 @@ public:
bool open(QString *errorString, const QString &fileName, quint64 offset = 0) { bool open(QString *errorString, const QString &fileName, quint64 offset = 0) {
QFile file(fileName); QFile file(fileName);
if (file.open(QIODevice::ReadOnly)) {
file.close();
quint64 size = static_cast<quint64>(file.size()); quint64 size = static_cast<quint64>(file.size());
if (size == 0 && !fileName.isEmpty()) { if (size == 0) {
QString msg = tr("The Binary Editor cannot open empty files."); QString msg = tr("The Binary Editor cannot open empty files.");
if (errorString) if (errorString)
*errorString = msg; *errorString = msg;
...@@ -278,8 +280,6 @@ public: ...@@ -278,8 +280,6 @@ public:
} }
if (offset >= size) if (offset >= size)
return false; return false;
if (file.open(QIODevice::ReadOnly)) {
file.close();
setFilePath(FileName::fromString(fileName)); setFilePath(FileName::fromString(fileName));
m_widget->setSizes(offset, file.size()); m_widget->setSizes(offset, file.size());
return true; return true;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment