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.
This commit is contained in:
Mario Hüttel 2020-07-10 21:43:30 +02:00
parent 0ec3e39284
commit 5c464f6fbb

View File

@ -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);