From 4a2bd440dd71faf6852d3653de02fc512ce8244f Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 14 May 2012 16:28:43 +0200 Subject: cocoa: handle failure on pixel format creation This didn't make any difference on with OpenGL 2.1, but with the introduction of OpenGL3.2 it's possible for the pixel format creation to fail (if OpenGL3.2 is not supported). This code handles the failure case accordingly. --- libvo/cocoa_common.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libvo/cocoa_common.m b/libvo/cocoa_common.m index 66f4cd3937..04b325405b 100644 --- a/libvo/cocoa_common.m +++ b/libvo/cocoa_common.m @@ -257,6 +257,12 @@ int vo_cocoa_create_window(struct vo *vo, uint32_t d_width, attr[i] = (NSOpenGLPixelFormatAttribute)0; s->pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attr] autorelease]; + if (!s->pixelFormat) { + mp_msg(MSGT_VO, MSGL_ERR, + "[cocoa] Invalid pixel format attribute " + "(GL3 not supported?)\n"); + return -1; + } s->glContext = [[NSOpenGLContext alloc] initWithFormat:s->pixelFormat shareContext:nil]; create_menu(); -- cgit v1.2.3