diff options
| author | Karl Heuer | 1994-10-27 18:44:47 +0000 |
|---|---|---|
| committer | Karl Heuer | 1994-10-27 18:44:47 +0000 |
| commit | 4d19cb8e06d296b1cc305b17d93471867fbe73ed (patch) | |
| tree | 29cad95d6c02489d8b81ead50f949f38438f91f6 /src | |
| parent | 7bfcceabaa587248fc72912beb8a3da513337f9e (diff) | |
| download | emacs-4d19cb8e06d296b1cc305b17d93471867fbe73ed.tar.gz emacs-4d19cb8e06d296b1cc305b17d93471867fbe73ed.zip | |
(set_frame_menubar): Don't copy string during GC risk.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xmenu.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/xmenu.c b/src/xmenu.c index 138f0484aa3..fffcdc4626e 100644 --- a/src/xmenu.c +++ b/src/xmenu.c | |||
| @@ -1377,7 +1377,7 @@ set_frame_menubar (f, first_time) | |||
| 1377 | Widget menubar_widget = f->display.x->menubar_widget; | 1377 | Widget menubar_widget = f->display.x->menubar_widget; |
| 1378 | int id = (int) f; | 1378 | int id = (int) f; |
| 1379 | Lisp_Object tail, items; | 1379 | Lisp_Object tail, items; |
| 1380 | widget_value *wv, *save_wv, *first_wv, *prev_wv = 0; | 1380 | widget_value *wv, *first_wv, *prev_wv = 0; |
| 1381 | int i; | 1381 | int i; |
| 1382 | 1382 | ||
| 1383 | BLOCK_INPUT; | 1383 | BLOCK_INPUT; |
| @@ -1386,7 +1386,7 @@ set_frame_menubar (f, first_time) | |||
| 1386 | wv->name = "menubar"; | 1386 | wv->name = "menubar"; |
| 1387 | wv->value = 0; | 1387 | wv->value = 0; |
| 1388 | wv->enabled = 1; | 1388 | wv->enabled = 1; |
| 1389 | save_wv = first_wv = wv; | 1389 | first_wv = wv; |
| 1390 | items = FRAME_MENU_BAR_ITEMS (f); | 1390 | items = FRAME_MENU_BAR_ITEMS (f); |
| 1391 | menu_items = f->menu_bar_vector; | 1391 | menu_items = f->menu_bar_vector; |
| 1392 | menu_items_allocated = XVECTOR (menu_items)->size; | 1392 | menu_items_allocated = XVECTOR (menu_items)->size; |
| @@ -1405,13 +1405,26 @@ set_frame_menubar (f, first_time) | |||
| 1405 | wv = single_submenu (key, string, maps); | 1405 | wv = single_submenu (key, string, maps); |
| 1406 | if (prev_wv) | 1406 | if (prev_wv) |
| 1407 | prev_wv->next = wv; | 1407 | prev_wv->next = wv; |
| 1408 | else | 1408 | else |
| 1409 | save_wv->contents = wv; | 1409 | first_wv->contents = wv; |
| 1410 | wv->name = (char *) XSTRING (string)->data; | 1410 | /* Don't set wv->name here; GC during the loop might relocate it. */ |
| 1411 | wv->enabled = 1; | 1411 | wv->enabled = 1; |
| 1412 | prev_wv = wv; | 1412 | prev_wv = wv; |
| 1413 | } | 1413 | } |
| 1414 | 1414 | ||
| 1415 | /* Now GC cannot happen during the lifetime of the widget_value, | ||
| 1416 | so it's safe to store data from a Lisp_String. */ | ||
| 1417 | wv = first_wv->contents; | ||
| 1418 | for (i = 0; i < XVECTOR (items)->size; i += 3) | ||
| 1419 | { | ||
| 1420 | Lisp_Object string; | ||
| 1421 | string = XVECTOR (items)->contents[i + 1]; | ||
| 1422 | if (NILP (string)) | ||
| 1423 | break; | ||
| 1424 | wv->name = (char *) XSTRING (string)->data; | ||
| 1425 | wv = wv->next; | ||
| 1426 | } | ||
| 1427 | |||
| 1415 | finish_menu_items (); | 1428 | finish_menu_items (); |
| 1416 | 1429 | ||
| 1417 | f->menu_bar_vector = menu_items; | 1430 | f->menu_bar_vector = menu_items; |