diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2015-01-01 14:38:08 +0100 |
---|---|---|
committer | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2015-01-01 14:38:08 +0100 |
commit | 64b6b2ea458f679ec0370878b1e54b2b1822c4b1 (patch) | |
tree | 0e694a2818886a6654f4ddf2b42af937d997214b /video/out/cocoa_common.m | |
parent | 39548ad9e961794e023aef0e281089064dd41f36 (diff) | |
download | mpv-64b6b2ea458f679ec0370878b1e54b2b1822c4b1.tar.bz2 mpv-64b6b2ea458f679ec0370878b1e54b2b1822c4b1.tar.xz |
cocoa: fix uninitialization while in fullscreen
This is only needed for switching video track with `_`, since Cocoa
automatically handles cleaning up the application's presentation options when
quitting the process.
Fixes #1399
Diffstat (limited to 'video/out/cocoa_common.m')
-rw-r--r-- | video/out/cocoa_common.m | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 01e28aceda..6dcdc16bae 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -189,12 +189,24 @@ void vo_cocoa_register_resize_callback(struct vo *vo, void vo_cocoa_uninit(struct vo *vo) { - with_cocoa_lock(vo, ^{ - struct vo_cocoa_state *s = vo->cocoa; + struct vo_cocoa_state *s = vo->cocoa; + NSView *ev = s->view; + + // keep the event view around for later in order to call -clear + if (!s->embedded) { + [ev retain]; + } + + with_cocoa_lock_on_main_thread(vo, ^{ enable_power_management(vo); cocoa_rm_fs_screen_profile_observer(vo); [s->gl_ctx release]; + + // needed to stop resize events triggered by the event's view -clear + // causing many uses after free + [s->video removeFromSuperview]; + [s->view removeFromSuperview]; [s->view release]; @@ -202,6 +214,15 @@ void vo_cocoa_uninit(struct vo *vo) if (s->window) [s->window release]; }); + + // don't use the mutex, because at that point it could have been destroyed + // and no one is accessing the events view anyway + if (!s->embedded) { + dispatch_async(dispatch_get_main_queue(), ^{ + [(MpvEventsView *)ev clear]; + [ev release]; + }); + } } static int get_screen_handle(struct vo *vo, int identifier, NSWindow *window, |