summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodger Combs <rodger.combs@gmail.com>2018-06-27 20:22:35 -0500
committerJan Ekström <jeebjp@gmail.com>2018-10-02 00:42:51 +0300
commit5b9cf1d0a6629ac0b657aa3bd5bbbcac161c8a15 (patch)
tree2825dc11691f3db4fd8bc8119a2111bee6936990
parenta985e8ed6b3444eba83763b96a27c414102c6f6e (diff)
downloadmpv-5b9cf1d0a6629ac0b657aa3bd5bbbcac161c8a15.tar.bz2
mpv-5b9cf1d0a6629ac0b657aa3bd5bbbcac161c8a15.tar.xz
mac: fix crash if we can't get an event tap
without assistive-device permissions the event tap can't be create on 10.14 any more which lead to an assertion. System Preferences > Security & Privacy > Privacy > Accessibility and add mpv or your terminal App to the list. (cherry picked from commit ada4f7c6006fc60189987b3ee012e7f4ced9926e)
-rw-r--r--osdep/macosx_events.m21
1 files changed, 12 insertions, 9 deletions
diff --git a/osdep/macosx_events.m b/osdep/macosx_events.m
index 0d46c0e906..a354378777 100644
--- a/osdep/macosx_events.m
+++ b/osdep/macosx_events.m
@@ -375,7 +375,8 @@ void cocoa_set_mpv_handle(struct mpv_handle *ctx)
- (void)restartMediaKeys
{
- CGEventTapEnable(self->_mk_tap_port, true);
+ if (self->_mk_tap_port)
+ CGEventTapEnable(self->_mk_tap_port, true);
}
- (void)setHighestPriotityMediaKeysTap
@@ -410,10 +411,10 @@ void cocoa_set_mpv_handle(struct mpv_handle *ctx)
tap_event_callback,
self);
- assert(self->_mk_tap_port != nil);
-
- NSMachPort *port = (NSMachPort *)self->_mk_tap_port;
- [[NSRunLoop mainRunLoop] addPort:port forMode:NSRunLoopCommonModes];
+ if (self->_mk_tap_port) {
+ NSMachPort *port = (NSMachPort *)self->_mk_tap_port;
+ [[NSRunLoop mainRunLoop] addPort:port forMode:NSRunLoopCommonModes];
+ }
});
}
@@ -421,10 +422,12 @@ void cocoa_set_mpv_handle(struct mpv_handle *ctx)
{
dispatch_async(dispatch_get_main_queue(), ^{
NSMachPort *port = (NSMachPort *)self->_mk_tap_port;
- CGEventTapEnable(self->_mk_tap_port, false);
- [[NSRunLoop mainRunLoop] removePort:port forMode:NSRunLoopCommonModes];
- CFRelease(self->_mk_tap_port);
- self->_mk_tap_port = nil;
+ if (port) {
+ CGEventTapEnable(self->_mk_tap_port, false);
+ [[NSRunLoop mainRunLoop] removePort:port forMode:NSRunLoopCommonModes];
+ CFRelease(self->_mk_tap_port);
+ self->_mk_tap_port = nil;
+ }
});
}