fixed crash in StringListwidget when scrolling with mouse

fixed #398
This commit is contained in:
thrust26 2018-12-15 10:17:14 +01:00
parent b8e53d76af
commit 06c20103af
3 changed files with 3 additions and 1 deletions

View File

@ -58,6 +58,7 @@ class ListWidget : public EditableWidget
const string& getSelectedString() const;
void scrollTo(int item);
void scrollToEnd() { scrollToCurrent(int(_list.size())); }
// Account for the extra width of embedded scrollbar
int getWidth() const override;

View File

@ -89,6 +89,7 @@ void LoggerDialog::loadConfig()
StringParser parser(instance().logMessages());
myLogInfo->setList(parser.stringList());
myLogInfo->setSelected(0);
myLogInfo->scrollToEnd();
myLogLevel->setSelected(instance().settings().getString("loglevel"), "1");
myLogToConsole->setState(instance().settings().getBool("logtoconsole"));

View File

@ -104,7 +104,7 @@ void StringListWidget::drawWidget(bool hilite)
GUI::Rect StringListWidget::getEditRect() const
{
GUI::Rect r(2, 1, _w - 2, _fontHeight);
const int offset = (_selectedItem - _currentPos) * _fontHeight;
const int offset = std::max(0, (_selectedItem - _currentPos) * _fontHeight);
r.top += offset;
r.bottom += offset;