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.
This commit is contained in:
Alexander Larsson 2020-01-30 15:17:59 +01:00
parent c69327caa8
commit 498ab6ac6c

View File

@ -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: