changeset 82289:26e674df63d5

(quit_dialog_event_loop) [TARGET_API_MAC_CARBON]: New variable. [TARGET_API_MAC_CARBON] (mac_handle_dialog_event): Set it if dialog event loop should be quit. [TARGET_API_MAC_CARBON] (create_and_show_dialog) [!MAC_OSX]: Quit dialog event loop if quit_dialog_event_loop is set.
author YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
date Mon, 06 Aug 2007 08:25:30 +0000
parents d2b18c3b227c
children 6502a9d89b26
files src/macmenu.c
diffstat 1 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/macmenu.c	Mon Aug 06 08:25:06 2007 +0000
+++ b/src/macmenu.c	Mon Aug 06 08:25:30 2007 +0000
@@ -2331,6 +2331,7 @@
   ((value) + DIALOG_BUTTON_COMMAND_ID_OFFSET)
 
 extern EMACS_TIME timer_check P_ ((int));
+static int quit_dialog_event_loop;
 
 static pascal OSStatus
 mac_handle_dialog_event (next_handler, event, data)
@@ -2340,7 +2341,6 @@
 {
   OSStatus err, result = eventNotHandledErr;
   WindowRef window = (WindowRef) data;
-  int quit_event_loop_p = 0;
 
   switch (GetEventClass (event))
     {
@@ -2355,7 +2355,7 @@
 	  if (DIALOG_BUTTON_COMMAND_ID_P (command.commandID))
 	    {
 	      SetWRefCon (window, command.commandID);
-	      quit_event_loop_p = 1;
+	      quit_dialog_event_loop = 1;
 	      break;
 	    }
 
@@ -2379,7 +2379,7 @@
 	  switch (char_code)
 	    {
 	    case kEscapeCharCode:
-	      quit_event_loop_p = 1;
+	      quit_dialog_event_loop = 1;
 	      break;
 
 	    default:
@@ -2395,7 +2395,7 @@
 					   NULL, &key_code);
 		if (err == noErr)
 		  if (mac_quit_char_key_p (modifiers, key_code))
-		    quit_event_loop_p = 1;
+		    quit_dialog_event_loop = 1;
 	      }
 	      break;
 	    }
@@ -2406,7 +2406,7 @@
       abort ();
     }
 
-  if (quit_event_loop_p)
+  if (quit_dialog_event_loop)
     {
       err = QuitEventLoop (GetCurrentEventLoop ());
       if (err == noErr)
@@ -2733,6 +2733,7 @@
     {
       EventTargetRef toolbox_dispatcher = GetEventDispatcherTarget ();
 
+      quit_dialog_event_loop = 0;
       while (1)
 	{
 	  EMACS_TIME next_time = timer_check (1);
@@ -2758,12 +2759,22 @@
 	      SendEventToEventTarget (event, toolbox_dispatcher);
 	      ReleaseEvent (event);
 	    }
+#ifdef MAC_OSX
 	  else if (err != eventLoopTimedOutErr)
 	    {
 	      if (err == eventLoopQuitErr)
 		err = noErr;
 	      break;
 	    }
+#else
+	  /* The return value of ReceiveNextEvent seems to be
+	     unreliable.  Use our own global variable instead.  */
+	  if (quit_dialog_event_loop)
+	    {
+	      err = noErr;
+	      break;
+	    }
+#endif
 	}
     }
   if (err == noErr)