From 498ab6ac6cd8681baa4f5bee0dd8a86e4191e9b7 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 30 Jan 2020 15:17:59 +0100 Subject: [PATCH] IconHelper: Only preload icons once This limits the amount of preloading we to, which can for instance avoid trashing if the icon cache is full, and in general do less work when its likely to be wasted such as when e.g. background-color for an icon helper changes. --- gtk/gtkiconhelper.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c index e266887c56..a940b9f657 100644 --- a/gtk/gtkiconhelper.c +++ b/gtk/gtkiconhelper.c @@ -48,6 +48,7 @@ struct _GtkIconHelper guint use_fallback : 1; guint force_scale_pixbuf : 1; guint texture_is_symbolic : 1; + guint preloaded : 1; GtkWidget *owner; GtkCssNode *node; @@ -184,6 +185,12 @@ _gtk_icon_helper_preload (GtkIconHelper *self) GIcon *gicon = NULL; GIcon *free_gicon = NULL; + /* Avoid constantly preloading as it may cause issues if we're trashing the icon cache */ + if (self->preloaded) + return; + + self->preloaded = TRUE; + switch (gtk_image_definition_get_storage_type (self->def)) { case GTK_IMAGE_ICON_NAME: -- 2.30.2