icontheme: make has_(g)icon consistent with lookup
authorvelsinki <112010-velsinki@users.noreply.gitlab.gnome.org>
Mon, 24 Apr 2023 21:38:20 +0000 (23:38 +0200)
committervelsinki <112010-velsinki@users.noreply.gitlab.gnome.org>
Mon, 24 Apr 2023 21:38:20 +0000 (23:38 +0200)
Make `gtk_icon_theme_has_icon` and `gtk_icon_theme_has_gicon` also
consider unthemed icons. This makes their behavior consistent with the
actual (documented) lookup behavior.

Fixes: #5709 and makes the workaround in nautilus@b643a00b obsolete
gtk/gtkicontheme.c

index f4191f9a77f8507a712aacd104f3d3859867fd7e..b07313340174293f59e8a2c59c88b219aba20432 100644 (file)
@@ -2592,7 +2592,8 @@ gtk_icon_theme_has_icon (GtkIconTheme *self,
 
   ensure_valid_themes (self, FALSE);
 
-  if (gtk_string_set_lookup (&self->icons, icon_name) != NULL)
+  if (gtk_string_set_lookup (&self->icons, icon_name) != NULL ||
+      g_hash_table_contains (self->unthemed_icons, icon_name))
     {
       res = TRUE;
       goto out;
@@ -2634,7 +2635,8 @@ gtk_icon_theme_has_gicon (GtkIconTheme *self,
 
   for (int i = 0; names[i]; i++)
     {
-      if (gtk_string_set_lookup (&self->icons, names[i]) != NULL)
+      if (gtk_string_set_lookup (&self->icons, names[i]) != NULL ||
+          g_hash_table_contains (self->unthemed_icons, names[i]))
         {
           res = TRUE;
           goto out;