diff options
author | Marek Olšák <maraeo@gmail.com> | 2012-11-29 00:50:57 +0100 |
---|---|---|
committer | Chad Versace <chad.versace@linux.intel.com> | 2012-11-29 09:17:09 -0800 |
commit | 10412ac893759cd95246c6461205547779206d31 (patch) | |
tree | f211eae4bcac5f25ccb68d492fb9b0cdea40df23 | |
parent | d0ca9c6566af84ec9caf74412b53e97ae71bf62f (diff) |
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().
-rw-r--r-- | src/waffle/glx/glx_context.c | 11 |
1 files changed, 11 insertions, 0 deletions
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; } |