forked from qt-creator/qt-creator
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 <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -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:
|
|||||||
}
|
}
|
||||||
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;
|
||||||
|
Reference in New Issue
Block a user