From 12057c8a30e4f64c86ef887c6a8a4c7fc7813f98 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 30 Jan 2023 08:24:02 -0500 Subject: [PATCH] gltexture: Small refactoring We do this in two places, so factor out the dropping of GL resources into a helper. --- gdk/gdkgltexture.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/gdk/gdkgltexture.c b/gdk/gdkgltexture.c index 4caaace442..a5be81e676 100644 --- a/gdk/gdkgltexture.c +++ b/gdk/gdkgltexture.c @@ -53,10 +53,8 @@ struct _GdkGLTextureClass { G_DEFINE_TYPE (GdkGLTexture, gdk_gl_texture, GDK_TYPE_TEXTURE) static void -gdk_gl_texture_dispose (GObject *object) +drop_gl_resources (GdkGLTexture *self) { - GdkGLTexture *self = GDK_GL_TEXTURE (object); - if (self->destroy) { self->destroy (self->data); @@ -66,6 +64,14 @@ gdk_gl_texture_dispose (GObject *object) g_clear_object (&self->context); self->id = 0; +} + +static void +gdk_gl_texture_dispose (GObject *object) +{ + GdkGLTexture *self = GDK_GL_TEXTURE (object); + + drop_gl_resources (self); g_clear_object (&self->saved); @@ -301,15 +307,7 @@ gdk_gl_texture_release (GdkGLTexture *self) self->saved = GDK_TEXTURE (gdk_memory_texture_from_texture (texture, gdk_texture_get_format (texture))); - if (self->destroy) - { - self->destroy (self->data); - self->destroy = NULL; - self->data = NULL; - } - - g_clear_object (&self->context); - self->id = 0; + drop_gl_resources (self); } static void