From 76f32e3881183b2fd321bd4a3e209d4144e1d323 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 3 Oct 2013 23:45:49 +0200 Subject: gl_x11: fail gracefully if selected FBconfig has no X visual glXGetVisualFromFBConfig() specifies specifies that it can return NULL if there is no associated X visual. Instead of crashing, let initialization fail. I'm not sure if this is actually supposed to work with a fallback visual (passing a NULL visual to vo_x11_config_vo_window would just do this), but let's play safe for now. Apparently this can happen when trying to use vo_opengl over a remote X display. --- video/out/gl_x11.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'video') diff --git a/video/out/gl_x11.c b/video/out/gl_x11.c index a3b3176987..99239d0b30 100644 --- a/video/out/gl_x11.c +++ b/video/out/gl_x11.c @@ -162,6 +162,8 @@ static GLXFBConfig select_fb_config(struct vo *vo, const int *attribs, int flags if (flags & VOFLAG_ALPHA) { for (int n = 0; n < fbcount; n++) { XVisualInfo *v = glXGetVisualFromFBConfig(vo->x11->display, fbc[n]); + if (!v) + continue; // This is a heuristic at best. Note that normal 8 bit Visuals use // a depth of 24, even if the pixels are padded to 32 bit. If the // depth is higher than 24, the remaining bits must be alpha. @@ -252,6 +254,10 @@ static bool config_window_x11(struct MPGLContext *ctx, uint32_t d_width, glx_ctx->fbc = fbc; glx_ctx->vinfo = glXGetVisualFromFBConfig(vo->x11->display, fbc); + if (!glx_ctx->vinfo) { + MP_ERR(vo, "Selected GLX FB config has no associated X visual\n"); + return false; + } MP_VERBOSE(vo, "GLX chose visual with ID 0x%x\n", (int)glx_ctx->vinfo->visualid); -- cgit v1.2.3