summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorAkemi <der.richter@gmx.de>2017-02-23 01:37:23 +0100
committerAkemi <der.richter@gmx.de>2017-02-27 23:57:44 +0100
commit9bd819a0bc809ab5af300e5d73e88f120c5d0285 (patch)
tree136b475a23ba3c22eec79dd8bccd74327f2869a7 /video
parent55fb4cb3f6938e8494b8b9a5eec9d56e656cf46b (diff)
downloadmpv-9bd819a0bc809ab5af300e5d73e88f120c5d0285.tar.bz2
mpv-9bd819a0bc809ab5af300e5d73e88f120c5d0285.tar.xz
cocoa: fix segfault in certain circumstances
i falsely assumed that the windowDidChangeScreen was meant to report ‘physical’ screen changes but was wondering why it triggers on other events too. it actually is a event that informs us when anything referenced by our current NSScreen is changed. even when something referenced in the NSScreen changed the old and new NSScreen are still equal if the physical screen didn’t change. with that my previous optimisation broke some cases where the physical screen didn’t change but things it referenced did, leading to a segfault when theses were accessed. to keep the optimisation we will always update our internal NSScreen reference but the rest only when the physical screen was changed.
Diffstat (limited to 'video')
-rw-r--r--video/out/cocoa/mpvadapter.h1
-rw-r--r--video/out/cocoa/window.m7
-rw-r--r--video/out/cocoa_common.m4
3 files changed, 9 insertions, 3 deletions
diff --git a/video/out/cocoa/mpvadapter.h b/video/out/cocoa/mpvadapter.h
index 65832aeae5..b5fa8adbf4 100644
--- a/video/out/cocoa/mpvadapter.h
+++ b/video/out/cocoa/mpvadapter.h
@@ -28,6 +28,7 @@
- (void)handleFilesArray:(NSArray *)files;
- (void)didChangeWindowedScreenProfile:(NSNotification *)notification;
- (void)performAsyncResize:(NSSize)size;
+- (void)windowDidChangePhysicalScreen;
- (BOOL)isInFullScreenMode;
- (BOOL)keyboardEnabled;
diff --git a/video/out/cocoa/window.m b/video/out/cocoa/window.m
index 028b17985f..88b1596d40 100644
--- a/video/out/cocoa/window.m
+++ b/video/out/cocoa/window.m
@@ -168,14 +168,15 @@
- (void)windowDidChangeScreen:(NSNotification *)notification
{
- //this event doesn't exclusively trigger on screen change
- //examples: screen reconfigure, toggling fullscreen
+ [self.adapter windowDidChangeScreen:notification];
+
if (!_is_animating && ![[self currentScreen] isEqual:[self screen]]) {
self.previousScreen = [self screen];
}
if (![[self currentScreen] isEqual:[self screen]]) {
- [self.adapter windowDidChangeScreen:notification];
+ [self.adapter windowDidChangePhysicalScreen];
}
+
self.currentScreen = [self screen];
}
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index f59ffd9005..e3f359eb5c 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -1018,6 +1018,10 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg)
- (void)windowDidChangeScreen:(NSNotification *)notification
{
vo_cocoa_update_screen_info(self.vout);
+}
+
+- (void)windowDidChangePhysicalScreen
+{
vo_cocoa_update_displaylink(self.vout);
flag_events(self.vout, VO_EVENT_WIN_STATE);
}