From cd7eac91d396b003399ae4f142abbe515febce90 Mon Sep 17 00:00:00 2001 From: Daemonratte Date: Thu, 30 Apr 2026 12:03:08 +0200 Subject: [PATCH] updateiconcache: ignore icons from unknown directories Do not add images from unknown icon-theme directories to the cache. Files that cannot be associated with a valid icon theme subdirectory should not be cached with the fallback directory index. Skipping them avoids listing random images from invalid locations in icon-theme.cache. Ported-from: Debian gtk+2.0 060_ignore-random-icons.patch --- gtk/updateiconcache.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gtk/updateiconcache.c b/gtk/updateiconcache.c index deda95872..82a05caeb 100644 --- a/gtk/updateiconcache.c +++ b/gtk/updateiconcache.c @@ -673,18 +673,18 @@ scan_directory (const gchar *base_path, flags |= HAS_SUFFIX_XPM; else if (g_str_has_suffix (name, ".icon")) flags |= HAS_ICON_FILE; - + if (flags == 0) continue; - + basename = g_strdup (name); dot = strrchr (basename, '.'); *dot = '\0'; - + image = g_hash_table_lookup (dir_hash, basename); if (!image) { - if (!dir_added) + if (!dir_added) { dir_added = TRUE; if (subdir) @@ -693,19 +693,19 @@ scan_directory (const gchar *base_path, directories = g_list_append (directories, g_strdup (subdir)); } else - dir_index = 0xffff; + continue; } - + image = g_new0 (Image, 1); image->dir_index = dir_index; g_hash_table_insert (dir_hash, g_strdup (basename), image); } image->flags |= flags; - + maybe_cache_image_data (image, path); maybe_cache_icon_data (image, path); - + g_free (basename); } @@ -716,7 +716,7 @@ scan_directory (const gchar *base_path, /* Move dir into the big file hash */ g_hash_table_foreach_remove (dir_hash, foreach_remove_func, files); - + g_hash_table_destroy (dir_hash); return directories;