Fix improper shift and mask order causing FS#6842

Set start_selected if exiting do_menu() early from more places


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12826 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2007-03-18 06:31:33 +00:00
parent 7d7135165d
commit b5e587c081
2 changed files with 9 additions and 5 deletions

View file

@ -176,7 +176,7 @@ static void menu_get_icon(int selected_item, void * data, ICON * icon)
static void init_menu_lists(const struct menu_item_ex *menu,
struct gui_synclist *lists, int selected, bool callback)
{
int i, count = (menu->flags&MENU_COUNT_MASK)>>MENU_COUNT_SHIFT;
int i, count = MENU_GET_COUNT(menu->flags);
menu_callback_type menu_callback = NULL;
ICON icon = NOICON;
current_subitems_count = 0;
@ -557,7 +557,10 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected)
if (temp->flags&MENU_FUNC_CHECK_RETVAL)
{
if (return_value == temp->function->exit_value)
return return_value;
{
done = true;
ret = return_value;
}
}
break;
}
@ -572,7 +575,8 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected)
if (in_stringlist)
{
action_signalscreenchange();
return selected;
done = true;
ret = selected;
}
else if (stack_top < MAX_MENUS)
{
@ -689,8 +693,7 @@ static void init_oldmenu(const struct menu_item_ex *menu,
(void)callback;
gui_synclist_init(lists, oldmenuwrapper_getname,
(void*)(intptr_t)menu->value, false, 1);
gui_synclist_set_nb_items(lists,
(menu->flags&MENU_COUNT_MASK)>>MENU_COUNT_SHIFT);
gui_synclist_set_nb_items(lists, MENU_GET_COUNT(menu->flags));
gui_synclist_limit_scroll(lists, true);
gui_synclist_select_item(lists, selected);
}

View file

@ -61,6 +61,7 @@ struct menu_func {
#define MENU_COUNT_MASK 0xFFF
#define MENU_COUNT_SHIFT 8
#define MENU_ITEM_COUNT(c) ((c&MENU_COUNT_MASK)<<MENU_COUNT_SHIFT)
#define MENU_GET_COUNT(flags) ((flags>>MENU_COUNT_SHIFT)&MENU_COUNT_MASK)
struct menu_item_ex {
unsigned int flags; /* above defines */