Config: Fix possible crash when navigating the config menu

This commit is contained in:
Maschell 2023-03-12 13:11:52 +01:00
parent 12c565681f
commit 21fec8e451

View File

@ -306,11 +306,15 @@ void ConfigUtils::displayMenu() {
auto cats = currentConfig->config->getCategories();
if (buttonsTriggered & VPAD_BUTTON_DOWN) {
if (selectedCat < cats.size() - 1) {
selectedItem = 0;
prevSelectedItem = 0;
selectedCat++;
redraw = true;
}
} else if (buttonsTriggered & VPAD_BUTTON_UP) {
if (selectedCat > 0) {
selectedItem = 0;
prevSelectedItem = 0;
selectedCat--;
redraw = true;
}
@ -339,6 +343,8 @@ void ConfigUtils::displayMenu() {
currentConfig = nullptr;
currentCategory = nullptr;
start = 0;
selectedItem = 0;
prevSelectedItem = 0;
end = MAX_BUTTONS_ON_SCREEN;
if (configs.size() < MAX_BUTTONS_ON_SCREEN) {
end = configs.size();