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.
This commit is contained in:
Benjamin Otte 2016-11-15 06:36:34 +01:00
parent c0aa065ac1
commit 4b8b06bb08
3 changed files with 8 additions and 2 deletions

View File

@ -48,7 +48,7 @@ struct _GtkIconHelperPrivate {
G_DEFINE_TYPE_WITH_PRIVATE (GtkIconHelper, gtk_icon_helper, GTK_TYPE_CSS_GADGET) G_DEFINE_TYPE_WITH_PRIVATE (GtkIconHelper, gtk_icon_helper, GTK_TYPE_CSS_GADGET)
static void void
gtk_icon_helper_invalidate (GtkIconHelper *self) gtk_icon_helper_invalidate (GtkIconHelper *self)
{ {
g_clear_pointer (&self->priv->texture, gsk_texture_unref); g_clear_pointer (&self->priv->texture, gsk_texture_unref);

View File

@ -132,6 +132,7 @@ gboolean _gtk_icon_helper_get_force_scale_pixbuf (GtkIconHelper *self);
void _gtk_icon_helper_set_force_scale_pixbuf (GtkIconHelper *self, void _gtk_icon_helper_set_force_scale_pixbuf (GtkIconHelper *self,
gboolean force_scale); gboolean force_scale);
void gtk_icon_helper_invalidate (GtkIconHelper *self);
void gtk_icon_helper_invalidate_for_change (GtkIconHelper *self, void gtk_icon_helper_invalidate_for_change (GtkIconHelper *self,
GtkCssStyleChange *change); GtkCssStyleChange *change);

View File

@ -1297,7 +1297,12 @@ gtk_image_unmap (GtkWidget *widget)
static void static void
gtk_image_unrealize (GtkWidget *widget) 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); GTK_WIDGET_CLASS (gtk_image_parent_class)->unrealize (widget);
} }