diff src/nsmenu.m @ 102004:e1a5d89a91dd

* nsfns.m (ns-read-file-name): BLOCK_INPUT while showing dialog. \n \n* nsmenu.m (pop_down_menu): Check popup_activated_flag. \n(ns_popup_dialog, EmacsDialogPanel-runDialogAt:): Let \npop_down_menu do the cleanup work as it is always called. (Bug#2154) \n \n* nsfont.m (nsfont_make_fontset_for_font): For now, don't try to \nset fontset font for 'mathematical-' sub-scripts. (Bug #2218)\n
author Adrian Robert <Adrian.B.Robert@gmail.com>
date Fri, 13 Feb 2009 13:30:35 +0000
parents 2ce0c9304190
children 6d9c8e198f1c
line wrap: on
line diff
--- a/src/nsmenu.m	Fri Feb 13 12:57:45 2009 +0000
+++ b/src/nsmenu.m	Fri Feb 13 13:30:35 2009 +0000
@@ -1494,12 +1494,15 @@
 pop_down_menu (Lisp_Object arg)
 {
   struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
-  popup_activated_flag = 0;
-  BLOCK_INPUT;
-  [NSApp endModalSession: popupSession];
-  [((EmacsDialogPanel *) (p->pointer)) close];
-  [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow];
-  UNBLOCK_INPUT;
+  if (popup_activated_flag)
+    {
+      popup_activated_flag = 0;
+      BLOCK_INPUT;
+      [NSApp endModalSession: popupSession];
+      [((EmacsDialogPanel *) (p->pointer)) close];
+      [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow];
+      UNBLOCK_INPUT;
+    }
   return Qnil;
 }
 
@@ -1565,12 +1568,8 @@
     record_unwind_protect (pop_down_menu, make_save_value (dialog, 0));
     popup_activated_flag = 1;
     tem = [dialog runDialogAt: p];
-    popup_activated_flag = 0;
-    unbind_to (specpdl_count, Qnil);
+    unbind_to (specpdl_count, Qnil);  /* calls pop_down_menu */
   }
-
-  [dialog close];
-  [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow];
   UNBLOCK_INPUT;
 
   return tem;
@@ -1879,6 +1878,7 @@
 {
   int ret;
 
+  /* initiate a session that will be ended by pop_down_menu */
   popupSession = [NSApp beginModalSessionForWindow: self];
   while (popup_activated_flag
          && (ret = [NSApp runModalSession: popupSession])
@@ -1889,7 +1889,6 @@
       timer_check (1);
       [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]];
     }
-  [NSApp endModalSession: popupSession];
 
   {				/* FIXME: BIG UGLY HACK!!! */
       Lisp_Object tmp;