[waffle] [PATCH] glx: make unsuccessful context creation not terminate the whole process

Marek Olšák maraeo at gmail.com
Wed Nov 28 15:50:57 PST 2012


---
 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;
 }
 
-- 
1.7.10.4



More information about the waffle mailing list