From c690d1f15d274d50ed21d4aa1b98a23de8d7e1e6 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Thu, 6 Oct 2022 10:52:34 +0800 Subject: [PATCH] Fix nsmenu crash when exiting popup dialog * src/nsmenu.m (pop_down_menu): Do not discard menu items here. (ns_popup_dialog): Call discard_menu_items after unuse_menu_items. (bug#58296) --- src/nsmenu.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/nsmenu.m b/src/nsmenu.m index ae795a0d22b..b06f737bacf 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -1551,7 +1551,6 @@ pop_down_menu (void *arg) #ifdef NS_IMPL_COCOA [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow]; #endif - discard_menu_items (); } } @@ -1599,6 +1598,7 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents) if (error_name) { + unbind_to (specpdl_count, Qnil); discard_menu_items (); [dialog close]; error ("%s", error_name); @@ -1608,6 +1608,9 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents) popup_activated_flag = 1; tem = [dialog runDialogAt: p]; unbind_to (specpdl_count, Qnil); + + /* This must come *after* unuse_menu_items. */ + discard_menu_items (); return tem; } -- 2.39.2