[gnome-software] Do not show duplicate lines in the 'OS Updates' entry
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Do not show duplicate lines in the 'OS Updates' entry
- Date: Wed, 12 Sep 2018 11:56:12 +0000 (UTC)
commit 9a9479cfcd40bdbb3d719ce94393682965cdc372
Author: Richard Hughes <richard hughsie com>
Date: Tue Sep 11 11:54:18 2018 +0100
Do not show duplicate lines in the 'OS Updates' entry
The generic packages never get an ID set, and so the deduplication never gets
done. In this case fall back to looking at the object addresses rather than
just blindly adding each one.
lib/gs-app-list.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/lib/gs-app-list.c b/lib/gs-app-list.c
index f30932ab..db3c7452 100644
--- a/lib/gs-app-list.c
+++ b/lib/gs-app-list.c
@@ -306,6 +306,16 @@ gs_app_list_check_for_duplicate (GsAppList *list, GsApp *app)
/* does not exist */
id = gs_app_get_unique_id (app);
+ if (id == NULL) {
+ for (guint i = 0; i < list->array->len; i++) {
+ GsApp *app_tmp = g_ptr_array_index (list->array, i);
+ if (app_tmp == app)
+ return FALSE;
+ }
+ /* not much else we can do... */
+ return TRUE;
+ }
+
app_old = g_hash_table_lookup (list->hash_by_id, id);
if (app_old == NULL)
return TRUE;
@@ -334,7 +344,11 @@ gs_app_list_add_safe (GsAppList *list, GsApp *app)
{
const gchar *id;
- /* if we're lazy-loading the ID then we can't filter for duplicates */
+ /* check for duplicate */
+ if (!gs_app_list_check_for_duplicate (list, app))
+ return;
+
+ /* if we're lazy-loading the ID then we can't use the ID hash */
id = gs_app_get_unique_id (app);
if (id == NULL) {
gs_app_list_maybe_watch_app (list, app);
@@ -342,10 +356,6 @@ gs_app_list_add_safe (GsAppList *list, GsApp *app)
return;
}
- /* check for duplicate */
- if (!gs_app_list_check_for_duplicate (list, app))
- return;
-
/* just use the ref */
gs_app_list_maybe_watch_app (list, app);
g_ptr_array_add (list->array, g_object_ref (app));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]