diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2015-02-17 10:21:41 +0000 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2015-02-17 10:21:41 +0000 |
commit | 0a4879b9ac5b3ab7766f91dcbb8f518a265b3a6b (patch) | |
tree | 2e8d123daef8b50218a2f4d00e11500c068044ad /gtk/gtkglarea.c | |
parent | da559c08f93d6832f4b9d3199cf5a22ac7f035f9 (diff) | |
download | gtk+-0a4879b9ac5b3ab7766f91dcbb8f518a265b3a6b.tar.gz |
glarea: Better error handling
Currently, GtkGLArea will leak GError instances set during the context
creation, if an error is set.
If any error is set post-context creation, it should be displayed even
in the case a GL context exists; for instance, we can use the error
display facility for shader compilation errors.
Diffstat (limited to 'gtk/gtkglarea.c')
-rw-r--r-- | gtk/gtkglarea.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/gtk/gtkglarea.c b/gtk/gtkglarea.c index a751f9ba12..d0453a1bac 100644 --- a/gtk/gtkglarea.c +++ b/gtk/gtkglarea.c @@ -253,7 +253,6 @@ gtk_gl_area_realize (GtkWidget *widget) &attributes, attributes_mask); gtk_widget_register_window (widget, priv->event_window); - g_clear_error (&priv->error); priv->context = NULL; g_signal_emit (area, area_signals[CREATE_CONTEXT], 0, &priv->context); @@ -292,10 +291,11 @@ gtk_gl_area_real_create_context (GtkGLArea *area) GdkGLContext *context; context = gdk_window_create_gl_context (gtk_widget_get_window (widget), &error); - if (priv->error != NULL) + if (error != NULL) { gtk_gl_area_set_error (area, error); g_clear_object (&context); + g_clear_error (&error); return NULL; } @@ -304,10 +304,11 @@ gtk_gl_area_real_create_context (GtkGLArea *area) priv->required_gl_version % 10); gdk_gl_context_realize (context, &error); - if (priv->error != NULL) + if (error != NULL) { gtk_gl_area_set_error (area, error); g_clear_object (&context); + g_clear_error (&error); return NULL; } @@ -524,13 +525,12 @@ gtk_gl_area_unrealize (GtkWidget *widget) gtk_gl_area_delete_buffers (area); } - /* Make sure to destroy if current */ + /* Make sure to unset the context if current */ if (priv->context == gdk_gl_context_get_current ()) gdk_gl_context_clear_current (); - g_object_unref (priv->context); - priv->context = NULL; } + g_clear_object (&priv->context); g_clear_error (&priv->error); if (priv->event_window != NULL) @@ -622,7 +622,7 @@ gtk_gl_area_draw (GtkWidget *widget, int w, h, scale; GLenum status; - if (priv->context == NULL) + if (priv->error != NULL) { gtk_gl_area_draw_error_screen (area, cr, |