diff options
author | der richter <der.richter@gmx.de> | 2020-02-22 12:22:16 +0100 |
---|---|---|
committer | der richter <der.richter@gmx.de> | 2020-02-22 13:56:31 +0100 |
commit | 327b092bfc1c0efacfe669d9a0c220ca921257fc (patch) | |
tree | f86324a74ea18d428c92f592c13356f2b8f5aaa3 | |
parent | 8e1ceaba343191996dfb280e8ce698675ea3ad43 (diff) | |
download | mpv-327b092bfc1c0efacfe669d9a0c220ca921257fc.tar.bz2 mpv-327b092bfc1c0efacfe669d9a0c220ca921257fc.tar.xz |
mac, cocoa: fix UI updates on none main queue threads
injecting the Apple Main Thread Checker via
DYLD_INSERT_LIBRARIES=libMainThreadChecker.dylib identified several
problems that needed fixing.
-rw-r--r-- | osdep/macosx_application.m | 10 | ||||
-rw-r--r-- | video/out/cocoa_common.m | 6 |
2 files changed, 11 insertions, 5 deletions
diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m index 958b67b948..10a992da2c 100644 --- a/osdep/macosx_application.m +++ b/osdep/macosx_application.m @@ -99,8 +99,10 @@ static Application *mpv_shared_app(void) static void terminate_cocoa_application(void) { - [NSApp hide:NSApp]; - [NSApp terminate:NSApp]; + dispatch_async(dispatch_get_main_queue(), ^{ + [NSApp hide:NSApp]; + [NSApp terminate:NSApp]; + }); } @implementation Application @@ -300,7 +302,9 @@ static void init_cocoa_application(bool regular) // Because activation policy has just been set to behave like a real // application, that policy must be reset on exit to prevent, among // other things, the menubar created here from remaining on screen. - [NSApp setActivationPolicy:NSApplicationActivationPolicyProhibited]; + dispatch_async(dispatch_get_main_queue(), ^{ + [NSApp setActivationPolicy:NSApplicationActivationPolicyProhibited]; + }); }); } diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 4779d35a1f..1940861dca 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -395,8 +395,10 @@ void vo_cocoa_init(struct vo *vo) cocoa_add_event_monitor(vo); if (!s->embedded) { - [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; - set_application_icon(NSApp); + run_on_main_thread(vo, ^{ + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + set_application_icon(NSApp); + }); } } |