From 1c80f5358110edd5777aeed15080249050ec2378 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Sun, 27 Aug 2023 10:54:44 -0400 Subject: [Bugfix] shuffle shenanigans from g5288 Fix #13369 shuffle & repeat callbacks shuffle and sort were called on startup before playlist_init and also on setting switch even without select repeat is also now handled in settings_list as well after moving the callbacks to settings_list.c there was then a problem of unintended callbacks on exit of the menus fixed that with F_CB_ON_SELECT_ONLY since the callback was called regardless of the setting being changed on F_CB_ON_SELECT_ONLY which is preferable in some circumstances I co-opted F_TEMPVAR to allow the callback only when the setting was changed with the flag F_CB_ON_SELECT_ONLY_IF_CHANGED Change-Id: I5265233bbb556dc06c45273e742be5d78510a806 --- apps/gui/option_select.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'apps/gui/option_select.c') diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index 8839f42e42..d7f27f64eb 100644 --- a/apps/gui/option_select.c +++ b/apps/gui/option_select.c @@ -470,7 +470,10 @@ bool option_screen(const struct settings_list *setting, int *variable; bool allow_wrap = setting->flags & F_NO_WRAP ? false : true; bool cb_on_select_only = - ((setting->flags & F_CB_ON_SELECT_ONLY) == F_CB_ON_SELECT_ONLY); + ((setting->flags & F_CB_ON_SELECT_ONLY) == F_CB_ON_SELECT_ONLY); + bool cb_on_changed = + ((setting->flags & F_CB_ON_SELECT_ONLY_IF_CHANGED) == F_CB_ON_SELECT_ONLY_IF_CHANGED); + int var_type = setting->flags&F_T_MASK; void (*function)(int) = NULL; char *title; @@ -561,8 +564,12 @@ bool option_screen(const struct settings_list *setting, } settings_save(); done = true; + if (cb_on_select_only && function) - function(*variable); + { + if (!cb_on_changed || (*variable != oldvalue)) + function(*variable); + } } else if(default_event_handler(action) == SYS_USB_CONNECTED) { -- cgit v1.2.3