mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
55fb4cb3f6
commit
9bd819a0bc
|
@ -28,6 +28,7 @@
|
|||
- (void)handleFilesArray:(NSArray *)files;
|
||||
- (void)didChangeWindowedScreenProfile:(NSNotification *)notification;
|
||||
- (void)performAsyncResize:(NSSize)size;
|
||||
- (void)windowDidChangePhysicalScreen;
|
||||
|
||||
- (BOOL)isInFullScreenMode;
|
||||
- (BOOL)keyboardEnabled;
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue