/* Fill in menu_items with the current menu bar contents.
This can evaluate Lisp code. */
+ save_menu_items ();
+
menu_items = f->menu_bar_vector;
menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0;
submenu_start = (int *) alloca (XVECTOR (items)->size * sizeof (int *));
}
set_buffer_internal_1 (prev);
- unbind_to (specpdl_count, Qnil);
/* If there has been no change in the Lisp-level contents
of the menu bar, skip redisplaying it. Just exit. */
if (i == menu_items_used && i == previous_menu_items_used && i != 0)
{
free_menubar_widget_value_tree (first_wv);
- menu_items = Qnil;
-
+ discard_menu_items ();
+ unbind_to (specpdl_count, Qnil);
return;
}
+ f->menu_bar_vector = menu_items;
+ f->menu_bar_items_used = menu_items_used;
+
+ /* This undoes save_menu_items. */
+ unbind_to (specpdl_count, Qnil);
+
/* Now GC cannot happen during the lifetime of the widget_value,
so it's safe to store data from a Lisp_String, as long as
local copies are made when the actual menu is created.
update_submenu_strings (wv->contents);
wv = wv->next;
}
-
- f->menu_bar_vector = menu_items;
- f->menu_bar_items_used = menu_items_used;
- menu_items = Qnil;
}
else
{
*error = NULL;
+ if (menu_items_n_panes == 0)
+ return Qnil;
+
if (menu_items_used <= MENU_ITEMS_PANE_LENGTH)
{
*error = "Empty menu";
abort ();
wv->selected = !NILP (selected);
+
if (!STRINGP (help))
help = Qnil;
first_wv->contents = wv_title;
}
+ /* No selection has been chosen yet. */
+ menu_item_selection = 0;
+
/* Actually create the menu. */
current_popup_menu = menu = CreatePopupMenu ();
fill_in_menu (menu, first_wv->contents);
pos.y = y;
ClientToScreen (FRAME_W32_WINDOW (f), &pos);
- /* No selection has been chosen yet. */
- menu_item_selection = 0;
-
/* Display the menu. */
menu_item_selection = SendMessage (FRAME_W32_WINDOW (f),
WM_EMACS_TRACKPOPUPMENU,