[gnome-software/1672-gnome-software-show-details-does-not-open-its-own-details-page: 5/5] gs-plugin-loader: Sort-truncate correct app list in the process thread
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1672-gnome-software-show-details-does-not-open-its-own-details-page: 5/5] gs-plugin-loader: Sort-truncate correct app list in the process thread
- Date: Fri, 11 Mar 2022 11:50:53 +0000 (UTC)
commit 7aa938899e302400f5e0d87627c2ead6eab82e44
Author: Milan Crha <mcrha redhat com>
Date: Tue Mar 8 14:25:37 2022 +0100
gs-plugin-loader: Sort-truncate correct app list in the process thread
The job's `list` can cache during the execution of the gs_plugin_loader_process_thread_cb(),
but the gs_plugin_loader_job_sorted_truncation() and gs_plugin_loader_job_sorted_truncation_again()
had been using job's list, which did not sort the result `list`, neither truncated it.
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1672
lib/gs-plugin-loader.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 6c72bb022..4bb4731e1 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -809,36 +809,37 @@ gs_plugin_loader_call_vfunc (GsPluginLoaderHelper *helper,
}
static void
-gs_plugin_loader_job_sorted_truncation_again (GsPluginLoaderHelper *helper)
+gs_plugin_loader_job_sorted_truncation_again (GsPluginJob *plugin_job,
+ GsAppList *list)
{
GsAppListSortFunc sort_func;
gpointer sort_func_data;
/* not valid */
- if (gs_plugin_job_get_list (helper->plugin_job) == NULL)
+ if (list == NULL)
return;
/* unset */
- sort_func = gs_plugin_job_get_sort_func (helper->plugin_job, &sort_func_data);
+ sort_func = gs_plugin_job_get_sort_func (plugin_job, &sort_func_data);
if (sort_func == NULL)
return;
- gs_app_list_sort (gs_plugin_job_get_list (helper->plugin_job), sort_func, sort_func_data);
+ gs_app_list_sort (list, sort_func, sort_func_data);
}
static void
-gs_plugin_loader_job_sorted_truncation (GsPluginLoaderHelper *helper)
+gs_plugin_loader_job_sorted_truncation (GsPluginJob *plugin_job,
+ GsAppList *list)
{
GsAppListSortFunc sort_func;
gpointer sort_func_data;
guint max_results;
- GsAppList *list = gs_plugin_job_get_list (helper->plugin_job);
/* not valid */
if (list == NULL)
return;
/* unset */
- max_results = gs_plugin_job_get_max_results (helper->plugin_job);
+ max_results = gs_plugin_job_get_max_results (plugin_job);
if (max_results == 0)
return;
@@ -849,9 +850,9 @@ gs_plugin_loader_job_sorted_truncation (GsPluginLoaderHelper *helper)
/* nothing set */
g_debug ("truncating results to %u from %u",
max_results, gs_app_list_length (list));
- sort_func = gs_plugin_job_get_sort_func (helper->plugin_job, &sort_func_data);
+ sort_func = gs_plugin_job_get_sort_func (plugin_job, &sort_func_data);
if (sort_func == NULL) {
- GsPluginAction action = gs_plugin_job_get_action (helper->plugin_job);
+ GsPluginAction action = gs_plugin_job_get_action (plugin_job);
g_debug ("no ->sort_func() set for %s, using random!",
gs_plugin_action_to_string (action));
gs_app_list_randomize (list);
@@ -3244,7 +3245,7 @@ gs_plugin_loader_process_thread_cb (GTask *task,
}
/* filter to reduce to a sane set */
- gs_plugin_loader_job_sorted_truncation (helper);
+ gs_plugin_loader_job_sorted_truncation (helper->plugin_job, list);
/* set the local file on any of the returned results */
switch (action) {
@@ -3426,7 +3427,7 @@ gs_plugin_loader_process_thread_cb (GTask *task,
gs_app_list_filter_duplicates (list, dedupe_flags);
/* sort these again as the refine may have added useful metadata */
- gs_plugin_loader_job_sorted_truncation_again (helper);
+ gs_plugin_loader_job_sorted_truncation_again (helper->plugin_job, list);
/* Hint that the job has finished. */
gs_plugin_loader_hint_job_finished (plugin_loader);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]