From: Jan Djärv Date: Sun, 5 Oct 2014 14:17:43 +0000 (+0200) Subject: * nsterm.m (ns_select, ns_read_socket): Use unwind_protect to decrease X-Git-Tag: emacs-25.0.90~2635^2~679^2~120 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=08f27aa39c498d34418c7420b33bf2db913827c3;p=emacs.git * nsterm.m (ns_select, ns_read_socket): Use unwind_protect to decrease apploopnr. Fixes: debbugs:18345 --- diff --git a/src/ChangeLog b/src/ChangeLog index fe0077b92b5..77494c0dc42 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -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. diff --git a/src/nsterm.m b/src/nsterm.m index 6e25716b239..332b7cc0b78 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -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) {