diff options
Diffstat (limited to 'src/xmenu.c')
| -rw-r--r-- | src/xmenu.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/xmenu.c b/src/xmenu.c index a7d47188ef5..8bb8d17369c 100644 --- a/src/xmenu.c +++ b/src/xmenu.c | |||
| @@ -2023,7 +2023,8 @@ x_menu_show (struct frame *f, int x, int y, int menuflags, | |||
| 2023 | Window root; | 2023 | Window root; |
| 2024 | XMenu *menu; | 2024 | XMenu *menu; |
| 2025 | int pane, selidx, lpane, status; | 2025 | int pane, selidx, lpane, status; |
| 2026 | Lisp_Object entry, pane_prefix; | 2026 | Lisp_Object entry = Qnil; |
| 2027 | Lisp_Object pane_prefix; | ||
| 2027 | char *datap; | 2028 | char *datap; |
| 2028 | int ulx, uly, width, height; | 2029 | int ulx, uly, width, height; |
| 2029 | int dispwidth, dispheight; | 2030 | int dispwidth, dispheight; |
| @@ -2045,6 +2046,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags, | |||
| 2045 | return Qnil; | 2046 | return Qnil; |
| 2046 | } | 2047 | } |
| 2047 | 2048 | ||
| 2049 | USE_SAFE_ALLOCA; | ||
| 2048 | block_input (); | 2050 | block_input (); |
| 2049 | 2051 | ||
| 2050 | /* Figure out which root window F is on. */ | 2052 | /* Figure out which root window F is on. */ |
| @@ -2057,8 +2059,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags, | |||
| 2057 | if (menu == NULL) | 2059 | if (menu == NULL) |
| 2058 | { | 2060 | { |
| 2059 | *error_name = "Can't create menu"; | 2061 | *error_name = "Can't create menu"; |
| 2060 | unblock_input (); | 2062 | goto return_entry; |
| 2061 | return Qnil; | ||
| 2062 | } | 2063 | } |
| 2063 | 2064 | ||
| 2064 | /* Don't GC while we prepare and show the menu, | 2065 | /* Don't GC while we prepare and show the menu, |
| @@ -2101,8 +2102,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags, | |||
| 2101 | { | 2102 | { |
| 2102 | XMenuDestroy (FRAME_X_DISPLAY (f), menu); | 2103 | XMenuDestroy (FRAME_X_DISPLAY (f), menu); |
| 2103 | *error_name = "Can't create pane"; | 2104 | *error_name = "Can't create pane"; |
| 2104 | unblock_input (); | 2105 | goto return_entry; |
| 2105 | return Qnil; | ||
| 2106 | } | 2106 | } |
| 2107 | i += MENU_ITEMS_PANE_LENGTH; | 2107 | i += MENU_ITEMS_PANE_LENGTH; |
| 2108 | 2108 | ||
| @@ -2146,9 +2146,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags, | |||
| 2146 | 2146 | ||
| 2147 | if (!NILP (descrip)) | 2147 | if (!NILP (descrip)) |
| 2148 | { | 2148 | { |
| 2149 | /* if alloca is fast, use that to make the space, | 2149 | item_data = SAFE_ALLOCA (maxwidth + SBYTES (descrip) + 1); |
| 2150 | to reduce gc needs. */ | ||
| 2151 | item_data = alloca (maxwidth + SBYTES (descrip) + 1); | ||
| 2152 | memcpy (item_data, SSDATA (item_name), SBYTES (item_name)); | 2150 | memcpy (item_data, SSDATA (item_name), SBYTES (item_name)); |
| 2153 | for (j = SCHARS (item_name); j < maxwidth; j++) | 2151 | for (j = SCHARS (item_name); j < maxwidth; j++) |
| 2154 | item_data[j] = ' '; | 2152 | item_data[j] = ' '; |
| @@ -2166,8 +2164,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags, | |||
| 2166 | { | 2164 | { |
| 2167 | XMenuDestroy (FRAME_X_DISPLAY (f), menu); | 2165 | XMenuDestroy (FRAME_X_DISPLAY (f), menu); |
| 2168 | *error_name = "Can't add selection to menu"; | 2166 | *error_name = "Can't add selection to menu"; |
| 2169 | unblock_input (); | 2167 | goto return_entry; |
| 2170 | return Qnil; | ||
| 2171 | } | 2168 | } |
| 2172 | i += MENU_ITEMS_ITEM_LENGTH; | 2169 | i += MENU_ITEMS_ITEM_LENGTH; |
| 2173 | lines++; | 2170 | lines++; |
| @@ -2241,7 +2238,7 @@ x_menu_show (struct frame *f, int x, int y, int menuflags, | |||
| 2241 | status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx, | 2238 | status = XMenuActivate (FRAME_X_DISPLAY (f), menu, &pane, &selidx, |
| 2242 | x, y, ButtonReleaseMask, &datap, | 2239 | x, y, ButtonReleaseMask, &datap, |
| 2243 | menu_help_callback); | 2240 | menu_help_callback); |
| 2244 | entry = pane_prefix = Qnil; | 2241 | pane_prefix = Qnil; |
| 2245 | 2242 | ||
| 2246 | switch (status) | 2243 | switch (status) |
| 2247 | { | 2244 | { |
| @@ -2300,10 +2297,10 @@ x_menu_show (struct frame *f, int x, int y, int menuflags, | |||
| 2300 | break; | 2297 | break; |
| 2301 | } | 2298 | } |
| 2302 | 2299 | ||
| 2300 | return_entry: | ||
| 2303 | unblock_input (); | 2301 | unblock_input (); |
| 2304 | unbind_to (specpdl_count, Qnil); | 2302 | SAFE_FREE (); |
| 2305 | 2303 | return unbind_to (specpdl_count, entry); | |
| 2306 | return entry; | ||
| 2307 | } | 2304 | } |
| 2308 | 2305 | ||
| 2309 | #endif /* not USE_X_TOOLKIT */ | 2306 | #endif /* not USE_X_TOOLKIT */ |