[gnome-software] appstream: Check if a stock icon actually exists in the theme before using it



commit d743f920867d8f57beac56191c8912147ef23c8f
Author: Matthias Klumpp <matthias tenstral net>
Date:   Fri Apr 24 04:22:13 2020 +0200

    appstream: Check if a stock icon actually exists in the theme before using it
    
    This resolves #918
    Missing stock icons occur quite frequently, as pretty much any icon can
    be overridden by the theme and therefore stock icon entries are
    plentiful, but no theme covers all icons.
    Of course, this change also protects us against wrong icon data.
    
    Many thanks to Laurent Bigonville for his work on this issue!

 plugins/core/gs-appstream.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index a98696b6..80b7384c 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -203,8 +203,14 @@ gs_appstream_refine_icon (GsPlugin *plugin, GsApp *app, XbNode *component)
        /* try a stock icon first */
        icon = gs_appstream_get_icon_by_kind (component, AS_ICON_KIND_STOCK);
        if (icon != NULL) {
-               gs_app_add_icon (app, icon);
-               return;
+               /* the icon referenced by the AppStream data may not be present in the current theme
+                * (usually more stock icon entries are added to permit huge themes like Papirus
+                * to style all apps in the software center), so we need to check for that here */
+               if (gtk_icon_theme_has_icon (gtk_icon_theme_get_default (),
+                                            as_icon_get_name (icon))) {
+                       gs_app_add_icon (app, icon);
+                       return;
+               }
        }
 
        /* if HiDPI get a 128px cached icon */


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