[gtk+/gtk-3-16] x11/gl: Trap GL context creation



commit d4c7fcd050b3d4eb8f8f7d322b44829198556fd8
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Wed Mar 25 14:34:42 2015 +0000

    x11/gl: Trap GL context creation
    
    Avoid an X11 error in case the context creation fails, so we can avoid a
    crash and pick it up in the upper layers, and display an error.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=746746

 gdk/x11/gdkglcontext-x11.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/gdk/x11/gdkglcontext-x11.c b/gdk/x11/gdkglcontext-x11.c
index e2d70e9..8beae33 100644
--- a/gdk/x11/gdkglcontext-x11.c
+++ b/gdk/x11/gdkglcontext-x11.c
@@ -558,17 +558,25 @@ create_gl3_context (GdkDisplay   *display,
     GLX_CONTEXT_FLAGS_ARB, flags,
     None,
   };
+  GLXContext res;
 
   GdkX11GLContext *share_x11 = NULL;
 
   if (share != NULL)
     share_x11 = GDK_X11_GL_CONTEXT (share);
 
-  return glXCreateContextAttribsARB (gdk_x11_display_get_xdisplay (display),
-                                     config,
-                                     share_x11 != NULL ? share_x11->glx_context : NULL,
-                                     True,
-                                     attrib_list);
+  gdk_x11_display_error_trap_push (display);
+
+  res = glXCreateContextAttribsARB (gdk_x11_display_get_xdisplay (display),
+                                    config,
+                                    share_x11 != NULL ? share_x11->glx_context : NULL,
+                                    True,
+                                    attrib_list);
+
+  if (gdk_x11_display_error_trap_pop (display))
+    return NULL;
+
+  return res;
 }
 
 static gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]