diff options
author | William Wilgus <me.theuser@yahoo.com> | 2019-09-20 19:23:18 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2019-09-20 19:23:18 -0500 |
commit | 60825970e93b6d9b4aec19456a1e7c142f904bd3 (patch) | |
tree | bcb05719bccf10727b3e5dc42e339db1785fa6b4 /apps | |
parent | 70aeac4666c4e222325088c55c82ed8ca576744a (diff) | |
download | rockbox-60825970e93b6d9b4aec19456a1e7c142f904bd3.tar.gz rockbox-60825970e93b6d9b4aec19456a1e7c142f904bd3.zip |
Bug fix menu -- general
Several places in the menu code assume MT_MENU though no guarantee existed
menu type is now explicitly checked prior to use of the submenu variable
Change-Id: Ib9013684309eb2d4cf4a8a809d097b096d3fcffc
Diffstat (limited to 'apps')
-rw-r--r-- | apps/menu.c | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/apps/menu.c b/apps/menu.c index 48f6fa3d0b..929a14e9f0 100644 --- a/apps/menu.c +++ b/apps/menu.c | |||
@@ -112,8 +112,8 @@ static const char* get_menu_item_name(int selected_item, | |||
112 | menu->menu_get_name_and_icon->list_get_name_data, buffer, buffer_len); | 112 | menu->menu_get_name_and_icon->list_get_name_data, buffer, buffer_len); |
113 | return menu->strings[selected_item]; | 113 | return menu->strings[selected_item]; |
114 | } | 114 | } |
115 | 115 | if (type == MT_MENU) | |
116 | menu = menu->submenus[selected_item]; | 116 | menu = menu->submenus[selected_item]; |
117 | 117 | ||
118 | if ((menu->flags&MENU_DYNAMIC_DESC) && (type != MT_SETTING_W_TEXT)) | 118 | if ((menu->flags&MENU_DYNAMIC_DESC) && (type != MT_SETTING_W_TEXT)) |
119 | return menu->menu_get_name_and_icon->list_get_name(selected_item, | 119 | return menu->menu_get_name_and_icon->list_get_name(selected_item, |
@@ -135,13 +135,16 @@ static enum themable_icons menu_get_icon(int selected_item, void * data) | |||
135 | { | 135 | { |
136 | const struct menu_item_ex *menu = (const struct menu_item_ex *)data; | 136 | const struct menu_item_ex *menu = (const struct menu_item_ex *)data; |
137 | int menu_icon = Icon_NOICON; | 137 | int menu_icon = Icon_NOICON; |
138 | int type = (menu->flags&MENU_TYPE_MASK); | ||
138 | selected_item = get_menu_selection(selected_item, menu); | 139 | selected_item = get_menu_selection(selected_item, menu); |
139 | 140 | ||
140 | if ((menu->flags&MENU_TYPE_MASK) == MT_RETURN_ID) | 141 | if (type == MT_RETURN_ID) |
141 | { | 142 | { |
142 | return Icon_Menu_functioncall; | 143 | return Icon_Menu_functioncall; |
143 | } | 144 | } |
144 | menu = menu->submenus[selected_item]; | 145 | if (type == MT_MENU) |
146 | menu = menu->submenus[selected_item]; | ||
147 | |||
145 | if (menu->flags&MENU_HAS_DESC) | 148 | if (menu->flags&MENU_HAS_DESC) |
146 | menu_icon = menu->callback_and_desc->icon_id; | 149 | menu_icon = menu->callback_and_desc->icon_id; |
147 | else if (menu->flags&MENU_DYNAMIC_DESC) | 150 | else if (menu->flags&MENU_DYNAMIC_DESC) |
@@ -353,7 +356,8 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected, | |||
353 | int selected = start_selected? *start_selected : 0; | 356 | int selected = start_selected? *start_selected : 0; |
354 | int action; | 357 | int action; |
355 | struct gui_synclist lists; | 358 | struct gui_synclist lists; |
356 | const struct menu_item_ex *temp, *menu = start_menu; | 359 | const struct menu_item_ex *temp = NULL; |
360 | const struct menu_item_ex *menu = start_menu; | ||
357 | int ret = 0; | 361 | int ret = 0; |
358 | bool redraw_lists; | 362 | bool redraw_lists; |
359 | int old_audio_status = audio_status(); | 363 | int old_audio_status = audio_status(); |
@@ -474,10 +478,16 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected, | |||
474 | } | 478 | } |
475 | else if (!in_stringlist) | 479 | else if (!in_stringlist) |
476 | { | 480 | { |
477 | int type; | 481 | int type = (menu->flags&MENU_TYPE_MASK); |
478 | selected = get_menu_selection(gui_synclist_get_sel_pos(&lists),menu); | 482 | selected = get_menu_selection(gui_synclist_get_sel_pos(&lists),menu); |
479 | temp = menu->submenus[selected]; | 483 | if (type == MT_MENU) |
480 | type = (temp->flags&MENU_TYPE_MASK); | 484 | { |
485 | temp = menu->submenus[selected]; | ||
486 | type = (temp->flags&MENU_TYPE_MASK); | ||
487 | } | ||
488 | else | ||
489 | type = -1; | ||
490 | |||
481 | if (type == MT_SETTING_W_TEXT || type == MT_SETTING) | 491 | if (type == MT_SETTING_W_TEXT || type == MT_SETTING) |
482 | { | 492 | { |
483 | #ifdef HAVE_QUICKSCREEN | 493 | #ifdef HAVE_QUICKSCREEN |
@@ -577,7 +587,7 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected, | |||
577 | } | 587 | } |
578 | else if (action == ACTION_STD_OK) | 588 | else if (action == ACTION_STD_OK) |
579 | { | 589 | { |
580 | int type; | 590 | int type = (menu->flags&MENU_TYPE_MASK); |
581 | /* entering an item that may not be a list, so stop scrolling */ | 591 | /* entering an item that may not be a list, so stop scrolling */ |
582 | gui_synclist_scroll_stop(&lists); | 592 | gui_synclist_scroll_stop(&lists); |
583 | #ifdef HAVE_BUTTONBAR | 593 | #ifdef HAVE_BUTTONBAR |
@@ -588,11 +598,15 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected, | |||
588 | } | 598 | } |
589 | #endif | 599 | #endif |
590 | selected = get_menu_selection(gui_synclist_get_sel_pos(&lists), menu); | 600 | selected = get_menu_selection(gui_synclist_get_sel_pos(&lists), menu); |
591 | temp = menu->submenus[selected]; | 601 | if (type == MT_MENU) |
602 | temp = menu->submenus[selected]; | ||
603 | else | ||
604 | type = -1; | ||
605 | |||
592 | redraw_lists = true; | 606 | redraw_lists = true; |
593 | if (in_stringlist) | 607 | if (in_stringlist) |
594 | type = (menu->flags&MENU_TYPE_MASK); | 608 | type = (menu->flags&MENU_TYPE_MASK); |
595 | else | 609 | else if (temp) |
596 | { | 610 | { |
597 | type = (temp->flags&MENU_TYPE_MASK); | 611 | type = (temp->flags&MENU_TYPE_MASK); |
598 | get_menu_callback(temp, &menu_callback); | 612 | get_menu_callback(temp, &menu_callback); |
@@ -665,6 +679,11 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected, | |||
665 | ret = temp->value; | 679 | ret = temp->value; |
666 | done = true; | 680 | done = true; |
667 | break; | 681 | break; |
682 | |||
683 | default: | ||
684 | ret = GO_TO_PREVIOUS; | ||
685 | done = true; | ||
686 | break; | ||
668 | } | 687 | } |
669 | if (type != MT_MENU) | 688 | if (type != MT_MENU) |
670 | { | 689 | { |