From 8e3a5269904997a726e636ed5114abdbf0739910 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 13 Jun 2014 17:42:43 +0300 Subject: [PATCH] Don't try to display menus and dialogs in an 'initial' frame. src/menu.c (Fx_popup_menu): Don't call the frame's menu_show_hook if the frame is the initial frame, because the hook is not set up then, and Emacs crashes. Reported by Fabrice Popineau . --- src/ChangeLog | 7 +++++++ src/menu.c | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index e1393f90627..7e3b4a97820 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2014-06-13 Eli Zaretskii + + * menu.c (Fx_popup_menu): Don't call the frame's menu_show_hook if + the frame is the initial frame, because the hook is not set up + then, and Emacs crashes. + Reported by Fabrice Popineau . + 2014-06-12 Stefan Monnier * keymap.c (silly_event_symbol_error): Don't recommend the use diff --git a/src/menu.c b/src/menu.c index 96f53903201..460dc7967b5 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1410,9 +1410,12 @@ no quit occurs and `x-popup-menu' returns nil. */) record_unwind_protect_void (discard_menu_items); #endif - /* Display them in a menu. */ - selection = FRAME_TERMINAL (f)->menu_show_hook (f, xpos, ypos, menuflags, - title, &error_name); + /* Display them in a menu, but not if F is the initial frame that + doesn't have its hooks set (e.g., in a batch session), because + such a frame cannot display menus. */ + if (!FRAME_INITIAL_P (f)) + selection = FRAME_TERMINAL (f)->menu_show_hook (f, xpos, ypos, menuflags, + title, &error_name); #ifdef HAVE_NS unbind_to (specpdl_count, Qnil); -- 2.39.2