[gnome-software/wip/mcrha/appstream-misc] gs-appstream: Change component kind only when can decode it from the string



commit 8e6e915d3e2af122f9d4ea9012d77916615f3231
Author: Milan Crha <mcrha redhat com>
Date:   Fri Sep 10 14:31:16 2021 +0200

    gs-appstream: Change component kind only when can decode it from the string
    
    This is to address occasional runtime warning about invalid kind
    change from generic to unknown, which happens when the saved component
    type cannot be decoded from the string to an enum. One such example
    is "shell-extension".

 lib/gs-appstream.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c
index 756106078..b049e7fb8 100644
--- a/lib/gs-appstream.c
+++ b/lib/gs-appstream.c
@@ -1063,8 +1063,11 @@ gs_appstream_refine_app (GsPlugin *plugin,
        /* set id kind */
        if (gs_app_get_kind (app) == AS_COMPONENT_KIND_UNKNOWN ||
            gs_app_get_kind (app) == AS_COMPONENT_KIND_GENERIC) {
+               AsComponentKind kind;
                tmp = xb_node_get_attr (component, "type");
-               gs_app_set_kind (app, as_component_kind_from_string (tmp));
+               kind = as_component_kind_from_string (tmp);
+               if (kind != AS_COMPONENT_KIND_UNKNOWN)
+                       gs_app_set_kind (app, kind);
        }
 
        /* set the release date */


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