summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2014-07-19 11:56:36 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2014-07-19 12:01:53 +0200
commitc76958d20c69fa83af7ae433f667b40d2734e504 (patch)
tree33328c36492e12f39389975f839f1577ec6ae5a3
parent1942e424e31df3e467522cca966429fd6c94429e (diff)
downloadmpv-c76958d20c69fa83af7ae433f667b40d2734e504.tar.bz2
mpv-c76958d20c69fa83af7ae433f667b40d2734e504.tar.xz
cocoa: don't send messages to uninitialized gl contexts
This should fix some crashes where we sent makeCurrentContext to a context that was being freed from another thread. /cc @mpv-player/stable
-rw-r--r--video/out/cocoa_common.m7
1 files changed, 6 insertions, 1 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index 4009f6cb26..2c3b5dafb2 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -345,6 +345,9 @@ static void vo_cocoa_resize_redraw(struct vo *vo, int width, int height)
if (!s->resize_redraw)
return;
+ if (!s->gl_ctx)
+ return;
+
vo_cocoa_set_current_context(vo, true);
[s->gl_ctx update];
@@ -400,6 +403,7 @@ void vo_cocoa_release_nsgl_ctx(struct vo *vo)
{
struct vo_cocoa_state *s = vo->cocoa;
[s->gl_ctx release];
+ s->gl_ctx = nil;
}
int vo_cocoa_config_window(struct vo *vo, uint32_t flags, void *gl_ctx)
@@ -454,7 +458,8 @@ void vo_cocoa_set_current_context(struct vo *vo, bool current)
if (!s->inside_sync_section)
[s->lock lock];
- [s->gl_ctx makeCurrentContext];
+ if (s->gl_ctx)
+ [s->gl_ctx makeCurrentContext];
} else {
[NSOpenGLContext clearCurrentContext];