1
0
Fork 0
forked from len0rd/rockbox

menu.c remove the check for valid menu_callback

instead of checking for menu callback use an empty callback instead

this code is a bit strange in that a prior valid callback might be returned
so I left the behavior but I question if thats really needed..

Change-Id: Id0c4eb208b33a6fffdbdffc63ea9cc928bba1a6d
This commit is contained in:
William Wilgus 2024-11-21 16:12:53 -05:00 committed by William Wilgus
parent d1a4903afb
commit e6f49e47e3

View file

@ -73,6 +73,13 @@ struct menu_data_t
int selected;
};
static int empty_menu_callback(int action, const struct menu_item_ex *this_item, struct gui_synclist *this_list)
{
return action;
(void)this_item;
(void)this_list;
}
static void get_menu_callback(const struct menu_item_ex *m,
menu_callback_type *menu_callback)
{
@ -80,6 +87,9 @@ static void get_menu_callback(const struct menu_item_ex *m,
*menu_callback= m->callback_and_desc->menu_callback;
else
*menu_callback = m->menu_callback;
if (!*menu_callback)
*menu_callback = &empty_menu_callback;
}
static bool query_audio_status(int *old_audio_status)
@ -201,7 +211,7 @@ static int init_menu_lists(const struct menu_item_ex *menu,
int start_action = ACTION_ENTER_MENUITEM;
int count = MIN(MENU_GET_COUNT(menu->flags), MAX_MENU_SUBITEMS);
int type = (menu->flags&MENU_TYPE_MASK);
menu_callback_type menu_callback = NULL;
menu_callback_type menu_callback = &empty_menu_callback;
int icon;
char * title;
current_subitems_count = 0;
@ -213,8 +223,7 @@ static int init_menu_lists(const struct menu_item_ex *menu,
{
if (type != MT_RETURN_ID)
get_menu_callback(menu->submenus[i],&menu_callback);
if (menu_callback)
{
if (menu_callback(ACTION_REQUEST_MENUITEM,
type==MT_RETURN_ID ? (void*)(intptr_t)i: menu->submenus[i], lists)
!= ACTION_EXIT_MENUITEM)
@ -223,12 +232,6 @@ static int init_menu_lists(const struct menu_item_ex *menu,
current_subitems_count++;
}
}
else
{
current_subitems[current_subitems_count] = i;
current_subitems_count++;
}
}
current_submenus_menu = (struct menu_item_ex *)menu;
@ -263,7 +266,7 @@ static int init_menu_lists(const struct menu_item_ex *menu,
gui_synclist_select_item(lists, find_menu_selection(selected));
get_menu_callback(menu,&menu_callback);
if (callback && menu_callback)
if (callback)
start_action = menu_callback(start_action, menu, lists);
return start_action;
@ -402,7 +405,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
int stack_top = 0;
struct viewport *vps = NULL;
menu_callback_type menu_callback = NULL;
menu_callback_type menu_callback = &empty_menu_callback;
/* if hide_theme is true, assume parent has been fixed before passed into
* this function, e.g. with viewport_set_defaults(parent, screen)
@ -441,8 +444,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
action = gui_synclist_do_touchscreen(&lists);
#endif
if (menu_callback)
{
int new_action = menu_callback(action, menu, &lists);
if (new_action == ACTION_EXIT_AFTER_THIS_MENUITEM)
ret = MENU_SELECTED_EXIT; /* exit after return from selection */
@ -450,7 +451,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
redraw_lists = true;
else
action = new_action;
}
if (LIKELY(gui_synclist_do_button(&lists, &action)))
continue;
@ -586,7 +586,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
bool exiting_menu = false;
in_stringlist = false;
if (menu_callback)
menu_callback(ACTION_EXIT_MENUITEM, menu, &lists);
if (menu->flags&MENU_EXITAFTERTHISMENU)
@ -630,13 +629,10 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
{
type = (temp->flags&MENU_TYPE_MASK);
get_menu_callback(temp, &menu_callback);
if (menu_callback)
{
action = menu_callback(ACTION_ENTER_MENUITEM, temp, &lists);
if (action == ACTION_EXIT_MENUITEM)
break;
}
}
switch (type)
{
case MT_MENU:
@ -715,7 +711,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
}
if (type != MT_MENU)
{
if (menu_callback)
menu_callback(ACTION_EXIT_MENUITEM, temp, &lists);
}
if (current_submenus_menu != menu)
@ -750,7 +745,6 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
if (redraw_lists && !done)
{
if (menu_callback)
if (menu_callback(ACTION_REDRAW, menu, &lists) != ACTION_REDRAW)
continue;