Mercurial > emacs
changeset 9725:98d374d51f4d
(set_frame_menubar): Don't copy string during GC risk.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 27 Oct 1994 18:44:47 +0000 |
parents | 193eeb5e78aa |
children | 51a9e9bc5fda |
files | src/xmenu.c |
diffstat | 1 files changed, 18 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/xmenu.c Thu Oct 27 18:29:49 1994 +0000 +++ b/src/xmenu.c Thu Oct 27 18:44:47 1994 +0000 @@ -1377,7 +1377,7 @@ Widget menubar_widget = f->display.x->menubar_widget; int id = (int) f; Lisp_Object tail, items; - widget_value *wv, *save_wv, *first_wv, *prev_wv = 0; + widget_value *wv, *first_wv, *prev_wv = 0; int i; BLOCK_INPUT; @@ -1386,7 +1386,7 @@ wv->name = "menubar"; wv->value = 0; wv->enabled = 1; - save_wv = first_wv = wv; + first_wv = wv; items = FRAME_MENU_BAR_ITEMS (f); menu_items = f->menu_bar_vector; menu_items_allocated = XVECTOR (menu_items)->size; @@ -1405,13 +1405,26 @@ wv = single_submenu (key, string, maps); if (prev_wv) prev_wv->next = wv; - else - save_wv->contents = wv; - wv->name = (char *) XSTRING (string)->data; + else + first_wv->contents = wv; + /* Don't set wv->name here; GC during the loop might relocate it. */ wv->enabled = 1; prev_wv = wv; } + /* Now GC cannot happen during the lifetime of the widget_value, + so it's safe to store data from a Lisp_String. */ + wv = first_wv->contents; + for (i = 0; i < XVECTOR (items)->size; i += 3) + { + Lisp_Object string; + string = XVECTOR (items)->contents[i + 1]; + if (NILP (string)) + break; + wv->name = (char *) XSTRING (string)->data; + wv = wv->next; + } + finish_menu_items (); f->menu_bar_vector = menu_items;