From 5c464f6fbb8b06701e5d67ebefa6d727397abcec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Fri, 10 Jul 2020 21:43:30 +0200 Subject: [PATCH] GtkGraphView: Fix dispose function * Chain to parent class's dispose function * Move OpenGL frees to 'unrelaize' signal because the GL context is still available there. --- lib/src/gtk-graph-view.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/src/gtk-graph-view.c b/lib/src/gtk-graph-view.c index 4e66d36..01c5d4d 100644 --- a/lib/src/gtk-graph-view.c +++ b/lib/src/gtk-graph-view.c @@ -107,9 +107,7 @@ void gtk_graph_view_dispose(GObject *obj) GtkGraphView *graph_view = GTK_GRAPH_VIEW(obj); GtkGraphViewPrivate *priv = gtk_graph_view_get_instance_private(graph_view); - if (priv->gl_area) - gtk_gl_area_make_current(GTK_GL_AREA(priv->gl_area)); - g_clear_object(&priv->passthrough_prog); + G_OBJECT_CLASS(gtk_graph_view_parent_class)->dispose(obj); } static GParamSpec *gtk_graph_view_properties[N_PROPERTIES] = {NULL}; @@ -161,6 +159,16 @@ static void gl_area_realize(GtkGLArea *area, GtkGraphView *graph_view) shimatta_opengl_graphics_realize(priv->test); } +static void gl_area_unrealize(GtkGLArea *area, GtkGraphView *graph_view) +{ + GtkGraphViewPrivate *priv; + + gtk_gl_area_make_current(area); + priv = gtk_graph_view_get_instance_private(graph_view); + + g_clear_object(&priv->passthrough_prog); +} + static void gl_area_resize(GtkGLArea *area, GtkGraphView *graph_view) { (void)graph_view; @@ -182,6 +190,7 @@ static void gtk_graph_view_init(GtkGraphView *obj) priv->gl_area = gtk_gl_area_new(); g_signal_connect(priv->gl_area, "render", G_CALLBACK(gl_render), obj); g_signal_connect(priv->gl_area, "realize", G_CALLBACK(gl_area_realize), obj); + g_signal_connect(priv->gl_area, "unrealize", G_CALLBACK(gl_area_unrealize), obj); g_signal_connect(priv->gl_area, "resize", G_CALLBACK(gl_area_resize), obj); gtk_container_add(GTK_CONTAINER(obj), priv->gl_area); gtk_box_set_child_packing(GTK_BOX(obj), priv->gl_area, TRUE, TRUE, 0, GTK_PACK_START);