[gnome-software/1485-gs-repos-dialog-can-show-also-desktop-applications] gs-plugin-loader: Ensure correct list is used on the job when refining wildcards



commit 18a893fa83ebd10cea75831e9d9a7398a60c14ce
Author: Milan Crha <mcrha redhat com>
Date:   Tue Oct 5 16:18:22 2021 +0200

    gs-plugin-loader: Ensure correct list is used on the job when refining wildcards
    
    The plugin job is reused when refining the apps, including the wildcards,
    but the gs_plugin_loader_run_refine_internal() can be called multiple times,
    with different lists. Adding refined wildcards to the original list causes
    invalid data being provided to the called.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1485

 lib/gs-plugin-loader.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 4d5240c32..7f5859a05 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -937,14 +937,24 @@ gs_plugin_loader_run_refine_internal (GsPluginLoaderHelper *helper,
                                      GCancellable *cancellable,
                                      GError **error)
 {
+       g_autoptr(GsAppList) previous_list = NULL;
+
+       if (list != gs_plugin_job_get_list (helper->plugin_job)) {
+               previous_list = g_object_ref (gs_plugin_job_get_list (helper->plugin_job));
+               gs_plugin_job_set_list (helper->plugin_job, list);
+       }
+
        /* try to adopt each application with a plugin */
        gs_plugin_loader_run_adopt (helper->plugin_loader, list);
 
        /* run each plugin */
        if (!gs_plugin_loader_run_refine_filter (helper, list,
                                                 GS_PLUGIN_REFINE_FLAGS_DEFAULT,
-                                                cancellable, error))
+                                                cancellable, error)) {
+               if (previous_list != NULL)
+                       gs_plugin_job_set_list (helper->plugin_job, previous_list);
                return FALSE;
+       }
 
        /* ensure these are sorted by score */
        if (gs_plugin_job_has_refine_flags (helper->plugin_job,
@@ -983,6 +993,8 @@ gs_plugin_loader_run_refine_internal (GsPluginLoaderHelper *helper,
                                                                   addons_list,
                                                                   cancellable,
                                                                   error)) {
+                               if (previous_list != NULL)
+                                       gs_plugin_job_set_list (helper->plugin_job, previous_list);
                                return FALSE;
                        }
                }
@@ -1004,6 +1016,8 @@ gs_plugin_loader_run_refine_internal (GsPluginLoaderHelper *helper,
                                                                   list2,
                                                                   cancellable,
                                                                   error)) {
+                               if (previous_list != NULL)
+                                       gs_plugin_job_set_list (helper->plugin_job, previous_list);
                                return FALSE;
                        }
                }
@@ -1032,11 +1046,16 @@ gs_plugin_loader_run_refine_internal (GsPluginLoaderHelper *helper,
                                                                   related_list,
                                                                   cancellable,
                                                                   error)) {
+                               if (previous_list != NULL)
+                                       gs_plugin_job_set_list (helper->plugin_job, previous_list);
                                return FALSE;
                        }
                }
        }
 
+       if (previous_list != NULL)
+               gs_plugin_job_set_list (helper->plugin_job, previous_list);
+
        /* success */
        return TRUE;
 }


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