changeset 95732:6488b258c0aa

(set_frame_menubar): Sync with version in xmenu.c. (w32_menu_show): Sync with xmenu_show in xmenu.c.
author Jason Rumney <jasonr@gnu.org>
date Mon, 09 Jun 2008 23:10:32 +0000
parents dce2a8a02b4e
children 0554ef53fccd
files src/w32menu.c
diffstat 1 files changed, 17 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/w32menu.c	Mon Jun 09 23:05:10 2008 +0000
+++ b/src/w32menu.c	Mon Jun 09 23:10:32 2008 +0000
@@ -702,6 +702,8 @@
 
       /* 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 *));
@@ -761,7 +763,6 @@
 	}
 
       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.  */
@@ -773,11 +774,17 @@
       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.
@@ -794,10 +801,6 @@
 	  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
     {
@@ -955,6 +958,9 @@
 
   *error = NULL;
 
+  if (menu_items_n_panes == 0)
+    return Qnil;
+
   if (menu_items_used <= MENU_ITEMS_PANE_LENGTH)
     {
       *error = "Empty menu";
@@ -1104,6 +1110,7 @@
 	    abort ();
 
 	  wv->selected = !NILP (selected);
+
           if (!STRINGP (help))
 	    help = Qnil;
 
@@ -1141,6 +1148,9 @@
       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);
@@ -1150,9 +1160,6 @@
   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,