[gnome-software/wip/show-metainfo-fixes] gs-appstream: Fix runtime check for non-NULL plugin for --show-metainfo



commit 9b4358ea4b67099ec291bd66be4948ec1221c179
Author: Milan Crha <mcrha redhat com>
Date:   Thu Aug 4 16:13:56 2022 +0200

    gs-appstream: Fix runtime check for non-NULL plugin for --show-metainfo
    
    The --show-metainfo calls the the first function with NULL 'plugin',
    thus the runtime check for the non-NULL argument breaks it.

 lib/gs-appstream.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c
index 78f6e5598..13eb352a8 100644
--- a/lib/gs-appstream.c
+++ b/lib/gs-appstream.c
@@ -22,7 +22,7 @@ gs_appstream_create_app (GsPlugin *plugin, XbSilo *silo, XbNode *component, GErr
        GsApp *app;
        g_autoptr(GsApp) app_new = NULL;
 
-       g_return_val_if_fail (GS_IS_PLUGIN (plugin), NULL);
+       /* The 'plugin' can be NULL, when creating app for --show-metainfo */
        g_return_val_if_fail (XB_IS_SILO (silo), NULL);
        g_return_val_if_fail (XB_IS_NODE (component), NULL);
 
@@ -39,6 +39,9 @@ gs_appstream_create_app (GsPlugin *plugin, XbSilo *silo, XbNode *component, GErr
        if (gs_app_has_quirk (app_new, GS_APP_QUIRK_IS_WILDCARD) || plugin == NULL)
                return g_steal_pointer (&app_new);
 
+       if (plugin == NULL)
+               return g_steal_pointer (&app_new);
+
        /* look for existing object */
        app = gs_plugin_cache_lookup (plugin, gs_app_get_unique_id (app_new));
        if (app != NULL)
@@ -978,7 +981,7 @@ gs_appstream_refine_app (GsPlugin *plugin,
        g_autoptr(GPtrArray) launchables = NULL;
        g_autoptr(XbNode) req = NULL;
 
-       g_return_val_if_fail (GS_IS_PLUGIN (plugin), FALSE);
+       /* The 'plugin' can be NULL, when creating app for --show-metainfo */
        g_return_val_if_fail (GS_IS_APP (app), FALSE);
        g_return_val_if_fail (XB_IS_SILO (silo), FALSE);
        g_return_val_if_fail (XB_IS_NODE (component), FALSE);


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