]> git.eshelyaron.com Git - emacs.git/commitdiff
* nsterm.m (ns_select, ns_read_socket): Use unwind_protect to decrease
authorJan Djärv <jan.h.d@swipnet.se>
Sun, 5 Oct 2014 14:17:43 +0000 (16:17 +0200)
committerJan Djärv <jan.h.d@swipnet.se>
Sun, 5 Oct 2014 14:17:43 +0000 (16:17 +0200)
apploopnr.

Fixes: debbugs:18345
src/ChangeLog
src/nsterm.m

index fe0077b92b53e3238d72b8d9ad2ecd17d587c9bc..77494c0dc4223c247bef21b7203d13d6605b1d3d 100644 (file)
@@ -2,6 +2,8 @@
 
        * nsterm.m (syms_of_nsterm): ns-use-fullscreen-animation is new.
        (toggleFullScreen:): Use ns-use-fullscreen-animation for animate.
+       (ns_select, ns_read_socket): Use unwind_protect to decrease
+       apploopnr (Bug#18345).
 
        * macfont.m: Fix indentation and import changes from macport
        24.3.94.
index 6e25716b239f649b41f0e37b0f80a30224195fd8..332b7cc0b78d862c0f7140f9799ea1e6022c2157 100644 (file)
@@ -3513,6 +3513,15 @@ ns_check_pending_open_menu ()
 }
 #endif /* NS_IMPL_COCOA) && >= MAC_OS_X_VERSION_10_5 */
 
+static void
+unwind_apploopnr (Lisp_Object not_used)
+{
+  --apploopnr;
+  n_emacs_events_pending = 0;
+  ns_finish_events ();
+  q_event_ptr = NULL;
+}
+
 static int
 ns_read_socket (struct terminal *terminal, struct input_event *hold_quit)
 /* --------------------------------------------------------------------------
@@ -3570,6 +3579,7 @@ ns_read_socket (struct terminal *terminal, struct input_event *hold_quit)
     }
   else
     {
+      ptrdiff_t specpdl_count = SPECPDL_INDEX ();
       /* Run and wait for events.  We must always send one NX_APPDEFINED event
          to ourself, otherwise [NXApp run] will never exit.  */
       send_appdefined = YES;
@@ -3579,8 +3589,9 @@ ns_read_socket (struct terminal *terminal, struct input_event *hold_quit)
         {
           emacs_abort ();
         }
+      record_unwind_protect (unwind_apploopnr, Qt);
       [NSApp run];
-      --apploopnr;
+      unbind_to (specpdl_count, Qnil);  /* calls unwind_apploopnr */
     }
 
   nevents = n_emacs_events_pending;
@@ -3687,8 +3698,14 @@ ns_select (int nfds, fd_set *readfds, fd_set *writefds,
     {
       emacs_abort ();
     }
-  [NSApp run];
-  --apploopnr;
+
+  {
+    ptrdiff_t specpdl_count = SPECPDL_INDEX ();
+    record_unwind_protect (unwind_apploopnr, Qt);
+    [NSApp run];
+    unbind_to (specpdl_count, Qnil);  /* calls unwind_apploopnr */
+  }
+
   ns_finish_events ();
   if (nr > 0 && readfds)
     {