From 8788c76bd93d54147980421acf9b9e5f6ba93b30 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 6 Feb 2020 10:17:13 +0100 Subject: [PATCH] icon theme: Also never fail in gtk_icon_theme_lookup_by_gicon() Similar to regular lookups, if the icon is some unknown type we return a missing-image. --- gtk/gtkicontheme.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index ed5af0dcf5..4911c71eb2 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -3541,9 +3541,8 @@ gtk_icon_paintable_new_for_pixbuf (GtkIconTheme *icon_theme, * #GtkIcon. The icon can then be rendered by using it as a #GdkPaintable, * or you can get information such as the filename and size. * - * Returns: (nullable) (transfer full): a #GtkIconPaintable containing - * information about the icon, or %NULL if the icon wasn’t - * found. Unref with g_object_unref() + * Returns: (transfer full): a #GtkIconPaintable containing + * information about the icon. Unref with g_object_unref() */ GtkIconPaintable * gtk_icon_theme_lookup_by_gicon (GtkIconTheme *self, @@ -3583,6 +3582,13 @@ gtk_icon_theme_lookup_by_gicon (GtkIconTheme *self, names = (const gchar **) g_themed_icon_get_names (G_THEMED_ICON (gicon)); icon = gtk_icon_theme_lookup_icon (self, names[0], &names[1], size, scale, direction, flags); } + else + { + g_debug ("Unhandled GIcon type %s", g_type_name_from_instance (gicon)); + icon = icon_paintable_new (size, scale); + icon->filename = g_strdup (IMAGE_MISSING_RESOURCE_PATH); + icon->is_resource = TRUE; + } return icon; }