emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/macmenu.c [emacs-unicode-2]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/src/macmenu.c [emacs-unicode-2]
Date: Sat, 04 Sep 2004 05:28:54 -0400

Index: emacs/src/macmenu.c
diff -c emacs/src/macmenu.c:1.11.2.3 emacs/src/macmenu.c:1.11.2.4
*** emacs/src/macmenu.c:1.11.2.3        Fri Aug 27 07:00:32 2004
--- emacs/src/macmenu.c Sat Sep  4 09:14:27 2004
***************
*** 90,99 ****
--- 90,101 ----
  typedef struct _widget_value
  {
    /* name of widget */
+   Lisp_Object   lname;
    char*               name;
    /* value (meaning depend on widget type) */
    char*               value;
    /* keyboard equivalent. no implications for XtTranslations */
+   Lisp_Object   lkey;
    char*               key;
    /* Help string or nil if none.
       GC finds this string through the frame's menu_bar_vector
***************
*** 1221,1232 ****
                save_wv->next = wv;
              else
                first_wv->contents = wv;
!             wv->name = pane_string;
!             /* Ignore the @ that means "separate pane".
!                This is a kludge, but this isn't worth more time.  */
!             if (!NILP (prefix) && wv->name[0] == '@')
!               wv->name++;
!             wv->value = 0;
              wv->enabled = 1;
              wv->button_type = BUTTON_TYPE_NONE;
              wv->help = Qnil;
--- 1223,1231 ----
                save_wv->next = wv;
              else
                first_wv->contents = wv;
!             wv->lname = pane_name;
!               /* Set value to 1 so update_submenu_strings can handle '@'  */
!             wv->value = (char *)1;
              wv->enabled = 1;
              wv->button_type = BUTTON_TYPE_NONE;
              wv->help = Qnil;
***************
*** 1269,1277 ****
          else
            save_wv->contents = wv;
  
!         wv->name = (char *) SDATA (item_name);
          if (!NILP (descrip))
!           wv->key = (char *) SDATA (descrip);
          wv->value = 0;
          /* The EMACS_INT cast avoids a warning.  There's no problem
             as long as pointers have enough bits to hold small integers.  */
--- 1268,1276 ----
          else
            save_wv->contents = wv;
  
!         wv->lname = item_name;
          if (!NILP (descrip))
!           wv->lkey = descrip;
          wv->value = 0;
          /* The EMACS_INT cast avoids a warning.  There's no problem
             as long as pointers have enough bits to hold small integers.  */
***************
*** 1310,1315 ****
--- 1309,1349 ----
  
    return first_wv;
  }
+ /* Walk through the widget_value tree starting at FIRST_WV and update
+    the char * pointers from the corresponding lisp values.
+    We do this after building the whole tree, since GC may happen while the
+    tree is constructed, and small strings are relocated.  So we must wait
+    until no GC can happen before storing pointers into lisp values.  */
+ static void
+ update_submenu_strings (first_wv)
+      widget_value *first_wv;
+ {
+   widget_value *wv;
+ 
+   for (wv = first_wv; wv; wv = wv->next)
+     {
+       if (wv->lname && ! NILP (wv->lname))
+         {
+           wv->name = SDATA (wv->lname);
+ 
+           /* Ignore the @ that means "separate pane".
+              This is a kludge, but this isn't worth more time.  */
+           if (wv->value == (char *)1)
+             {
+               if (wv->name[0] == '@')
+               wv->name++;
+               wv->value = 0;
+             }
+         }
+ 
+       if (wv->lkey && ! NILP (wv->lkey))
+         wv->key = SDATA (wv->lkey);
+ 
+       if (wv->contents)
+         update_submenu_strings (wv->contents);
+     }
+ }
+ 
  
  /* Set the contents of the menubar widgets of frame F.
     The argument FIRST_TIME is currently ignored;
***************
*** 1388,1395 ****
  
        items = FRAME_MENU_BAR_ITEMS (f);
  
-       inhibit_garbage_collection ();
- 
        /* Save the frame's previous menu bar contents data.  */
        if (previous_menu_items_used)
        bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items,
--- 1422,1427 ----
***************
*** 1454,1459 ****
--- 1486,1492 ----
          if (NILP (string))
            break;
          wv->name = (char *) SDATA (string);
+           update_submenu_strings (wv->contents);
          wv = wv->next;
        }
  
***************
*** 1807,1815 ****
    /* Get the refcon to find the correct item*/
    if (menu_item_selection)
      {
!       menu = GetMenuHandle (HiWord (menu_item_choice));
!       if (menu) {
!       GetMenuItemRefCon (menu, menu_item_selection, &refcon);
        }
      }
  
--- 1840,1848 ----
    /* Get the refcon to find the correct item*/
    if (menu_item_selection)
      {
!       MenuHandle sel_menu = GetMenuHandle (HiWord (menu_item_choice));
!       if (sel_menu) {
!       GetMenuItemRefCon (sel_menu, menu_item_selection, &refcon);
        }
      }
  
***************
*** 1831,1841 ****
    {
      int i = MIN_POPUP_SUBMENU_ID;
      MenuHandle submenu = GetMenuHandle (i);
!     while (menu != NULL)
        {
        DeleteMenu (i);
!       DisposeMenu (menu);
!       menu = GetMenuHandle (++i);
        }
    }
  
--- 1864,1874 ----
    {
      int i = MIN_POPUP_SUBMENU_ID;
      MenuHandle submenu = GetMenuHandle (i);
!     while (submenu != NULL)
        {
        DeleteMenu (i);
!       DisposeMenu (submenu);
!       submenu = GetMenuHandle (++i);
        }
    }
  
***************
*** 2207,2213 ****
               int force_disable)
  {
    Str255 item_name;
!   int pos, i;
  
    if (name_is_separator (wv->name))
      AppendMenu (menu, "\p-");
--- 2240,2246 ----
               int force_disable)
  {
    Str255 item_name;
!   int pos;
  
    if (name_is_separator (wv->name))
      AppendMenu (menu, "\p-");
***************
*** 2263,2271 ****
        else
        SetItemMark (menu, pos, noMark);
        }
-     }
  
!   SetMenuItemRefCon (menu, pos, (UInt32) wv->call_data);
  
    if (submenu != NULL)
      SetMenuItemHierarchicalID (menu, pos, submenu);
--- 2296,2304 ----
        else
        SetItemMark (menu, pos, noMark);
        }
  
!       SetMenuItemRefCon (menu, pos, (UInt32) wv->call_data);
!     }
  
    if (submenu != NULL)
      SetMenuItemHierarchicalID (menu, pos, submenu);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]