From fee5ceccad7d021503b278a7b5dd596efa030ba1 Mon Sep 17 00:00:00 2001 From: Akemi Date: Thu, 29 Dec 2016 20:04:44 +0100 Subject: cocoa: don't change Space on quit in fullscreen circumvent undefined behavior when quitting in fullscreen. Fixes #3957 --- video/out/cocoa_common.m | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 0b10217f80..d00d5d78c7 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -387,6 +387,16 @@ void vo_cocoa_uninit(struct vo *vo) pthread_cond_signal(&s->wakeup); pthread_mutex_unlock(&s->lock); + // close window beforehand to prevent undefined behavior when in fullscreen + // that resets the desktop to space 1 + run_on_main_thread(vo, ^{ + // if using --wid + libmpv there's no window to release + if (s->window) { + [s->window setDelegate:nil]; + [s->window close]; + } + }); + run_on_main_thread(vo, ^{ enable_power_management(s); vo_cocoa_uninit_displaylink(s); @@ -406,12 +416,6 @@ void vo_cocoa_uninit(struct vo *vo) [s->view removeFromSuperview]; [s->view release]; - // if using --wid + libmpv there's no window to release - if (s->window) { - [s->window setDelegate:nil]; - [s->window close]; - } - if (!s->embedded) [s->blankCursor release]; -- cgit v1.2.3