Commit 6c99b8f5 authored by hjk's avatar hjk Committed by Christian Kandeler

bineditor: fix cursor down in small files

The cursor was not movable when the file fit on a single screen
without a scrollbar.

Change-Id: I758eff6d1baa7dd6232c9b10c58ccf42f717ed6f
Reviewed-by: default avatarChristian Kandeler <christian.kandeler@digia.com>
parent 18cff29d
......@@ -1051,7 +1051,8 @@ bool BinEditor::event(QEvent *e)
return true;
case Qt::Key_Down: {
const QScrollBar * const scrollBar = verticalScrollBar();
if (scrollBar->value() >= scrollBar->maximum() - 1) {
const int maximum = scrollBar->maximum();
if (maximum && scrollBar->value() >= maximum - 1) {
emit newRangeRequested(editor(), baseAddress() + m_size);
return true;
}
......
......@@ -222,7 +222,8 @@ public:
bool open(QString *errorString, const QString &fileName, quint64 offset = 0) {
QFile file(fileName);
if (offset >= static_cast<quint64>(file.size())) {
quint64 size = static_cast<quint64>(file.size());
if (size == 0) {
QString msg = tr("The Binary Editor can not open empty files.");
if (errorString)
*errorString = msg;
......@@ -230,6 +231,8 @@ public:
QMessageBox::critical(Core::ICore::mainWindow(), tr("File Error"), msg);
return false;
}
if (offset >= size)
return false;
if (file.open(QIODevice::ReadOnly)) {
file.close();
m_fileName = fileName;
......
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