[gnome-shell/T27795: 63/138] Load fallback image-missing image when no other icon was loaded



commit b6a7ba7f0418aa06dd695ae3ef0ae569c385e8b9
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Wed May 10 15:59:32 2017 +0100

    Load fallback image-missing image when no other icon was loaded
    
    If a given icon is not available for neither the current theme nor any
    of the fallback options (default theme -"Adwaita", "gnome"...), the
    call to gtk_icon_theme_lookup_by_gicon() will return a NULL value, which
    returned by the Shell Toolkit as is, causing trouble in the Shell's JS
    code when calling shell_app_create_icon_texture() to create an icon.
    
    To at least mitigate the chances of this having this issue happening, we
    should at least try to load the standad 'image-missing' icon from the
    Icon Naming Specification spec when we receive a NULL here, so that
    at least we try to show something to the user, even if it's ugly.
    
    https://phabricator.endlessm.com/T11550

 src/st/st-texture-cache.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c
index 53df7195b8..01d2fcd804 100644
--- a/src/st/st-texture-cache.c
+++ b/src/st/st-texture-cache.c
@@ -34,6 +34,8 @@
 #define CACHE_PREFIX_FILE "file:"
 #define CACHE_PREFIX_FILE_FOR_CAIRO "file-for-cairo:"
 
+#define IMAGE_MISSING_ICON_NAME "image-missing"
+
 struct _StTextureCachePrivate
 {
   GtkIconTheme *icon_theme;
@@ -989,7 +991,12 @@ st_texture_cache_load_gicon (StTextureCache    *cache,
                                                    size, scale,
                                                    lookup_flags);
   if (info == NULL)
-    return NULL;
+    {
+      /* Do not give up without even trying to pick the image-missing fallback icon. */
+      info = gtk_icon_theme_lookup_icon_for_scale (theme, IMAGE_MISSING_ICON_NAME, size, scale,  
GTK_ICON_LOOKUP_USE_BUILTIN);
+      if (info == NULL)
+        return NULL;
+    }
 
   gicon_string = g_icon_to_string (icon);
   /* A return value of NULL indicates that the icon can not be serialized,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]