From 10412ac893759cd95246c6461205547779206d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 29 Nov 2012 00:50:57 +0100 Subject: glx: make unsuccessful context creation not terminate the whole process glXCreateContextAttribs() emits GLXBadFBConfig under some circumstances, and Xlib's default error handler calls exit(). To avoid the exit(), install a temporary error handlers around the call to glXCreateContextAttribs(). --- src/waffle/glx/glx_context.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/waffle/glx/glx_context.c b/src/waffle/glx/glx_context.c index e3a37ea..80e874d 100644 --- a/src/waffle/glx/glx_context.c +++ b/src/waffle/glx/glx_context.c @@ -110,6 +110,11 @@ glx_context_fill_attrib_list(struct glx_config *config, return true; } +static int glx_dummy_error_handler(Display *dpy, XErrorEvent *err) +{ + return 0; +} + static GLXContext glx_context_create_native(struct glx_config *config, struct glx_context *share_ctx) @@ -118,6 +123,10 @@ glx_context_create_native(struct glx_config *config, GLXContext real_share_ctx = share_ctx ? share_ctx->glx : NULL; struct glx_display *dpy = glx_display(config->wcore.display); struct glx_platform *platform = glx_platform(dpy->wcore.platform); + int (*old_error_handler)(Display *, XErrorEvent *); + + /* This prevents Xlib from killing the process if there's an error. */ + old_error_handler = XSetErrorHandler(glx_dummy_error_handler); if (dpy->ARB_create_context) { bool ok; @@ -152,6 +161,8 @@ glx_context_create_native(struct glx_config *config, } } + XSetErrorHandler(old_error_handler); + return ctx; } -- cgit v1.2.3