summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>2017-01-06 15:51:48 +0000
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>2017-01-09 23:52:24 +0000
commitf6c7cd81b83ec45b9d0c5a8798685fd143859eeb (patch)
treea0ad7c16e6a4f1dd5ec0ac182a8a003c7a927a53
parent54616de3c44d9db199aba2025305abfa471e38c7 (diff)
downloadnautilus-f6c7cd81b83ec45b9d0c5a8798685fd143859eeb.tar.gz
icon-info: hash/store icons using scale factor as well as size
Otherwise we might pick up an icon at an invalid size for a given scale. https://bugzilla.gnome.org/show_bug.cgi?id=776896
-rw-r--r--src/nautilus-icon-info.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/nautilus-icon-info.c b/src/nautilus-icon-info.c
index 0a83c7411..29d795607 100644
--- a/src/nautilus-icon-info.c
+++ b/src/nautilus-icon-info.c
@@ -162,12 +162,14 @@ nautilus_icon_info_new_for_icon_info (GtkIconInfo *icon_info,
typedef struct
{
GIcon *icon;
+ int scale;
int size;
} LoadableIconKey;
typedef struct
{
char *filename;
+ int scale;
int size;
} ThemedIconKey;
@@ -266,7 +268,7 @@ nautilus_icon_info_clear_caches (void)
static guint
loadable_icon_key_hash (LoadableIconKey *key)
{
- return g_icon_hash (key->icon) ^ key->size;
+ return g_icon_hash (key->icon) ^ key->scale ^ key->size;
}
static gboolean
@@ -274,17 +276,20 @@ loadable_icon_key_equal (const LoadableIconKey *a,
const LoadableIconKey *b)
{
return a->size == b->size &&
+ a->scale == b->scale &&
g_icon_equal (a->icon, b->icon);
}
static LoadableIconKey *
loadable_icon_key_new (GIcon *icon,
+ int scale,
int size)
{
LoadableIconKey *key;
key = g_slice_new (LoadableIconKey);
key->icon = g_object_ref (icon);
+ key->scale = scale;
key->size = size;
return key;
@@ -308,17 +313,20 @@ themed_icon_key_equal (const ThemedIconKey *a,
const ThemedIconKey *b)
{
return a->size == b->size &&
+ a->scale == b->scale &&
g_str_equal (a->filename, b->filename);
}
static ThemedIconKey *
themed_icon_key_new (const char *filename,
+ int scale,
int size)
{
ThemedIconKey *key;
key = g_slice_new (ThemedIconKey);
key->filename = g_strdup (filename);
+ key->scale = scale;
key->size = size;
return key;
@@ -355,7 +363,8 @@ nautilus_icon_info_lookup (GIcon *icon,
}
lookup_key.icon = icon;
- lookup_key.size = size;
+ lookup_key.scale = scale;
+ lookup_key.size = size * scale;
icon_info = g_hash_table_lookup (loadable_icon_cache, &lookup_key);
if (icon_info)
@@ -379,7 +388,7 @@ nautilus_icon_info_lookup (GIcon *icon,
icon_info = nautilus_icon_info_new_for_pixbuf (pixbuf, scale);
- key = loadable_icon_key_new (icon, size);
+ key = loadable_icon_key_new (icon, scale, size);
g_hash_table_insert (loadable_icon_cache, key, icon_info);
return g_object_ref (icon_info);
@@ -421,6 +430,7 @@ nautilus_icon_info_lookup (GIcon *icon,
}
lookup_key.filename = (char *) filename;
+ lookup_key.scale = scale;
lookup_key.size = size;
icon_info = g_hash_table_lookup (themed_icon_cache, &lookup_key);
@@ -432,7 +442,7 @@ nautilus_icon_info_lookup (GIcon *icon,
icon_info = nautilus_icon_info_new_for_icon_info (gtkicon_info, scale);
- key = themed_icon_key_new (filename, size);
+ key = themed_icon_key_new (filename, scale, size);
g_hash_table_insert (themed_icon_cache, key, icon_info);
g_object_unref (gtkicon_info);