From c547371caa3d46ab3ca40647a64972a1c1fef198 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Fri, 4 Sep 2020 19:40:57 +0200 Subject: [PATCH] [Table] SEGFAULT fixed --- radio/src/thirdparty/libopenui/src/table.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/radio/src/thirdparty/libopenui/src/table.cpp b/radio/src/thirdparty/libopenui/src/table.cpp index af683af4e..3fc1b7e39 100644 --- a/radio/src/thirdparty/libopenui/src/table.cpp +++ b/radio/src/thirdparty/libopenui/src/table.cpp @@ -75,6 +75,9 @@ void Table::Body::onEvent(event_t event) } } if (event == EVT_ROTARY_RIGHT) { + if (lines.empty()) + return; + int newSelection = (selection + 1) % lines.size(); select(newSelection, true); auto onSelect = lines[selection].onSelect; @@ -83,7 +86,10 @@ void Table::Body::onEvent(event_t event) } } else if (event == EVT_ROTARY_LEFT) { - int newSelection = selection == 0 ? lines.size() - 1 : selection - 1; + if (lines.empty()) + return; + + int newSelection = selection <= 0 ? lines.size() - 1 : selection - 1; select(newSelection, true); auto onSelect = lines[selection].onSelect; if (onSelect) {