diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32menu.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/w32menu.c b/src/w32menu.c index e3fdf29ac95..cb3e8f37082 100644 --- a/src/w32menu.c +++ b/src/w32menu.c | |||
| @@ -702,6 +702,8 @@ set_frame_menubar (f, first_time, deep_p) | |||
| 702 | 702 | ||
| 703 | /* Fill in menu_items with the current menu bar contents. | 703 | /* Fill in menu_items with the current menu bar contents. |
| 704 | This can evaluate Lisp code. */ | 704 | This can evaluate Lisp code. */ |
| 705 | save_menu_items (); | ||
| 706 | |||
| 705 | menu_items = f->menu_bar_vector; | 707 | menu_items = f->menu_bar_vector; |
| 706 | menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0; | 708 | menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0; |
| 707 | submenu_start = (int *) alloca (XVECTOR (items)->size * sizeof (int *)); | 709 | submenu_start = (int *) alloca (XVECTOR (items)->size * sizeof (int *)); |
| @@ -761,7 +763,6 @@ set_frame_menubar (f, first_time, deep_p) | |||
| 761 | } | 763 | } |
| 762 | 764 | ||
| 763 | set_buffer_internal_1 (prev); | 765 | set_buffer_internal_1 (prev); |
| 764 | unbind_to (specpdl_count, Qnil); | ||
| 765 | 766 | ||
| 766 | /* If there has been no change in the Lisp-level contents | 767 | /* If there has been no change in the Lisp-level contents |
| 767 | of the menu bar, skip redisplaying it. Just exit. */ | 768 | of the menu bar, skip redisplaying it. Just exit. */ |
| @@ -773,11 +774,17 @@ set_frame_menubar (f, first_time, deep_p) | |||
| 773 | if (i == menu_items_used && i == previous_menu_items_used && i != 0) | 774 | if (i == menu_items_used && i == previous_menu_items_used && i != 0) |
| 774 | { | 775 | { |
| 775 | free_menubar_widget_value_tree (first_wv); | 776 | free_menubar_widget_value_tree (first_wv); |
| 776 | menu_items = Qnil; | 777 | discard_menu_items (); |
| 777 | 778 | unbind_to (specpdl_count, Qnil); | |
| 778 | return; | 779 | return; |
| 779 | } | 780 | } |
| 780 | 781 | ||
| 782 | f->menu_bar_vector = menu_items; | ||
| 783 | f->menu_bar_items_used = menu_items_used; | ||
| 784 | |||
| 785 | /* This undoes save_menu_items. */ | ||
| 786 | unbind_to (specpdl_count, Qnil); | ||
| 787 | |||
| 781 | /* Now GC cannot happen during the lifetime of the widget_value, | 788 | /* Now GC cannot happen during the lifetime of the widget_value, |
| 782 | so it's safe to store data from a Lisp_String, as long as | 789 | so it's safe to store data from a Lisp_String, as long as |
| 783 | local copies are made when the actual menu is created. | 790 | local copies are made when the actual menu is created. |
| @@ -794,10 +801,6 @@ set_frame_menubar (f, first_time, deep_p) | |||
| 794 | update_submenu_strings (wv->contents); | 801 | update_submenu_strings (wv->contents); |
| 795 | wv = wv->next; | 802 | wv = wv->next; |
| 796 | } | 803 | } |
| 797 | |||
| 798 | f->menu_bar_vector = menu_items; | ||
| 799 | f->menu_bar_items_used = menu_items_used; | ||
| 800 | menu_items = Qnil; | ||
| 801 | } | 804 | } |
| 802 | else | 805 | else |
| 803 | { | 806 | { |
| @@ -955,6 +958,9 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error) | |||
| 955 | 958 | ||
| 956 | *error = NULL; | 959 | *error = NULL; |
| 957 | 960 | ||
| 961 | if (menu_items_n_panes == 0) | ||
| 962 | return Qnil; | ||
| 963 | |||
| 958 | if (menu_items_used <= MENU_ITEMS_PANE_LENGTH) | 964 | if (menu_items_used <= MENU_ITEMS_PANE_LENGTH) |
| 959 | { | 965 | { |
| 960 | *error = "Empty menu"; | 966 | *error = "Empty menu"; |
| @@ -1104,6 +1110,7 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error) | |||
| 1104 | abort (); | 1110 | abort (); |
| 1105 | 1111 | ||
| 1106 | wv->selected = !NILP (selected); | 1112 | wv->selected = !NILP (selected); |
| 1113 | |||
| 1107 | if (!STRINGP (help)) | 1114 | if (!STRINGP (help)) |
| 1108 | help = Qnil; | 1115 | help = Qnil; |
| 1109 | 1116 | ||
| @@ -1141,6 +1148,9 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error) | |||
| 1141 | first_wv->contents = wv_title; | 1148 | first_wv->contents = wv_title; |
| 1142 | } | 1149 | } |
| 1143 | 1150 | ||
| 1151 | /* No selection has been chosen yet. */ | ||
| 1152 | menu_item_selection = 0; | ||
| 1153 | |||
| 1144 | /* Actually create the menu. */ | 1154 | /* Actually create the menu. */ |
| 1145 | current_popup_menu = menu = CreatePopupMenu (); | 1155 | current_popup_menu = menu = CreatePopupMenu (); |
| 1146 | fill_in_menu (menu, first_wv->contents); | 1156 | fill_in_menu (menu, first_wv->contents); |
| @@ -1150,9 +1160,6 @@ w32_menu_show (f, x, y, for_click, keymaps, title, error) | |||
| 1150 | pos.y = y; | 1160 | pos.y = y; |
| 1151 | ClientToScreen (FRAME_W32_WINDOW (f), &pos); | 1161 | ClientToScreen (FRAME_W32_WINDOW (f), &pos); |
| 1152 | 1162 | ||
| 1153 | /* No selection has been chosen yet. */ | ||
| 1154 | menu_item_selection = 0; | ||
| 1155 | |||
| 1156 | /* Display the menu. */ | 1163 | /* Display the menu. */ |
| 1157 | menu_item_selection = SendMessage (FRAME_W32_WINDOW (f), | 1164 | menu_item_selection = SendMessage (FRAME_W32_WINDOW (f), |
| 1158 | WM_EMACS_TRACKPOPUPMENU, | 1165 | WM_EMACS_TRACKPOPUPMENU, |