[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] [emacs] 01/01: Time-out NS event loop
From: |
David Reitter |
Subject: |
[Emacs-diffs] [emacs] 01/01: Time-out NS event loop |
Date: |
Fri, 14 Nov 2014 23:08:42 +0000 |
davidswelt pushed a commit to branch master
in repository emacs.
commit 658b768a6534ae6e77a8547a56fc31b46b63710b
Author: David Reitter <address@hidden>
Date: Fri Nov 14 10:56:39 2014 -0500
Time-out NS event loop
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:address@hidden
Fixes debbugs:18993
---
src/ChangeLog | 5 +++++
src/nsterm.m | 23 ++++++++++++-----------
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 3bcac1b..71b2938 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2014-11-14 David Reitter <address@hidden>
+
+ * nsterm.m (run): set timeout for event loop to prevent hang.
+ (Bug#18993)
+
2014-11-14 Paul Eggert <address@hidden>
* .gitignore: Add emacs-[1-9]*, to ignore files like emacs-25.0.50.1.
diff --git a/src/nsterm.m b/src/nsterm.m
index 64951da..539f77e 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -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);