From 21fec8e451f0eed9f78ef350d62093ccd9b2c43c Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 12 Mar 2023 13:11:52 +0100 Subject: [PATCH] Config: Fix possible crash when navigating the config menu --- source/utils/ConfigUtils.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/utils/ConfigUtils.cpp b/source/utils/ConfigUtils.cpp index 808f201..5ffdaae 100644 --- a/source/utils/ConfigUtils.cpp +++ b/source/utils/ConfigUtils.cpp @@ -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; } @@ -336,10 +340,12 @@ void ConfigUtils::displayMenu() { redraw = true; continue; } else if (buttonsTriggered & VPAD_BUTTON_B) { - currentConfig = nullptr; - currentCategory = nullptr; - start = 0; - end = MAX_BUTTONS_ON_SCREEN; + 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(); }