[gtk+] image: Invalidate icon helper when unrealizing



commit 4b8b06bb082787d4b194493f135ad77de691b2fe
Author: Benjamin Otte <otte redhat com>
Date:   Tue Nov 15 06:36:34 2016 +0100

    image: Invalidate icon helper when unrealizing
    
    This frees up any cached surfaces and textures in the iconhelper,
    ensuring that the renderer can release its texture data.

 gtk/gtkiconhelper.c        |    2 +-
 gtk/gtkiconhelperprivate.h |    1 +
 gtk/gtkimage.c             |    7 ++++++-
 3 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c
index 5bd099d..e02e43f 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -48,7 +48,7 @@ struct _GtkIconHelperPrivate {
 
 G_DEFINE_TYPE_WITH_PRIVATE (GtkIconHelper, gtk_icon_helper, GTK_TYPE_CSS_GADGET)
 
-static void
+void
 gtk_icon_helper_invalidate (GtkIconHelper *self)
 {
   g_clear_pointer (&self->priv->texture, gsk_texture_unref);
diff --git a/gtk/gtkiconhelperprivate.h b/gtk/gtkiconhelperprivate.h
index 0fd3240..acfdd20 100644
--- a/gtk/gtkiconhelperprivate.h
+++ b/gtk/gtkiconhelperprivate.h
@@ -132,6 +132,7 @@ gboolean _gtk_icon_helper_get_force_scale_pixbuf (GtkIconHelper *self);
 void     _gtk_icon_helper_set_force_scale_pixbuf (GtkIconHelper *self,
                                                   gboolean       force_scale);
 
+void      gtk_icon_helper_invalidate (GtkIconHelper *self);
 void      gtk_icon_helper_invalidate_for_change (GtkIconHelper     *self,
                                                  GtkCssStyleChange *change);
 
diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c
index ffb5f81..4d5e8d7 100644
--- a/gtk/gtkimage.c
+++ b/gtk/gtkimage.c
@@ -1297,7 +1297,12 @@ gtk_image_unmap (GtkWidget *widget)
 static void
 gtk_image_unrealize (GtkWidget *widget)
 {
-  gtk_image_reset_anim_iter (GTK_IMAGE (widget));
+  GtkImage *image = GTK_IMAGE (widget);
+  GtkImagePrivate *priv = image->priv;
+
+  gtk_image_reset_anim_iter (image);
+
+  gtk_icon_helper_invalidate (priv->icon_helper);
 
   GTK_WIDGET_CLASS (gtk_image_parent_class)->unrealize (widget);
 }


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