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

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,19 +267,19 @@ public:
bool open(QString *errorString, const QString &fileName, quint64 offset = 0) {
QFile file(fileName);
quint64 size = static_cast<quint64>(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<quint64>(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;
......
Markdown is supported
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