GUI: Fix crash in TextViewer

This commit is contained in:
Eugene Sandulenko 2023-03-25 17:30:11 +01:00
parent b0dbb83a84
commit 10c3eb8ebc
No known key found for this signature in database
GPG Key ID: 014D387312D34F08

View File

@ -157,6 +157,14 @@ void TextViewerDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 d
switch (cmd) {
case kSetPositionCmd:
_currentPos = _scrollBar->_currentPos;
if (_currentPos < 0) {
_currentPos = 0;
}
if ((_currentPos + _linesPerPage) >= (int)_linesArray.size()) {
_currentPos = MAX<int32>(_linesArray.size() - _linesPerPage, 0);
}
drawDialog(kDrawLayerForeground);
break;
default:
@ -199,7 +207,7 @@ void TextViewerDialog::handleKeyDown(Common::KeyState state) {
_currentPos = 0;
}
if ((_currentPos + _linesPerPage) >= (int)_linesArray.size()) {
_currentPos = _linesArray.size() - _linesPerPage;
_currentPos = MAX<int32>(_linesArray.size() - _linesPerPage, 0);
}
drawDialog(kDrawLayerForeground);