]> git.eshelyaron.com Git - emacs.git/commitdiff
Time-out NS event loop
authorDavid Reitter <david.reitter@gmail.com>
Fri, 14 Nov 2014 15:56:39 +0000 (10:56 -0500)
committerDavid Reitter <david.reitter@gmail.com>
Fri, 14 Nov 2014 23:07:31 +0000 (18:07 -0500)
OS X 10.10 will, at times, not send us the application-defined
event that is used to terminate the event loop.  As a workaround,
we define a timeout and react accordingly.  Leaving it in place
for other OSX and NS versions as a safety net.

Partial revert of 2014-11-08T16:32:37Z!jan.h.d@swipnet.se.

Fixes debbugs:18993

src/ChangeLog
src/nsterm.m

index 3bcac1bff33128bb5d9a91d0847fbd1c3a1e7f09..71b2938694b4a05bd6cd29fc6216c54a0e326da6 100644 (file)
@@ -1,3 +1,8 @@
+2014-11-14  David Reitter  <david.reitter@gmail.com>
+
+       * nsterm.m (run): set timeout for event loop to prevent hang.
+       (Bug#18993)
+
 2014-11-14  Paul Eggert  <eggert@cs.ucla.edu>
 
        * .gitignore: Add emacs-[1-9]*, to ignore files like emacs-25.0.50.1.
index 64951da308facdcfba92a6c0cd4e9efc9cfd7681..539f77e512edefec23d8eb975c18f1a3ff3f2c8c 100644 (file)
@@ -4511,15 +4511,6 @@ ns_term_shutdown (int sig)
 #ifdef NS_IMPL_COCOA
 - (void)run
 {
-#ifndef NSAppKitVersionNumber10_9
-#define NSAppKitVersionNumber10_9 1265
-#endif
-
-    if ((int)NSAppKitVersionNumber != NSAppKitVersionNumber10_9)
-      {
-        [super run];
-        return;
-      }
 
   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 
@@ -4532,12 +4523,22 @@ ns_term_shutdown (int sig)
       [pool release];
       pool = [[NSAutoreleasePool alloc] init];
 
+      /* OSX 10.10.1 swallows the AppDefined event we are sending ourselves
+        in certain situations (rapid incoming events).
+        The timeout we set with untilDate is necessary to prevent a hang.
+        Bug #18993 */
+
       NSEvent *event =
         [self nextEventMatchingMask:NSAnyEventMask
-                          untilDate:[NSDate distantFuture]
+                          untilDate:[NSDate dateWithTimeIntervalSinceNow:0.5]
                              inMode:NSDefaultRunLoopMode
                             dequeue:YES];
-      [self sendEvent:event];
+
+      if (event == nil) // timeout
+       shouldKeepRunning = NO;
+      else
+       [self sendEvent:event];
+
       [self updateWindows];
     } while (shouldKeepRunning);