[gnome-software/gnome-3-22] Fix weirdness when de-duplicating applications
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-22] Fix weirdness when de-duplicating applications
- Date: Tue, 20 Sep 2016 14:13:51 +0000 (UTC)
commit 73fed63fc55482603dda31ecf67224c89abe0d31
Author: Richard Hughes <richard hughsie com>
Date: Tue Sep 20 14:29:42 2016 +0100
Fix weirdness when de-duplicating applications
This took some time to find. When we were adding the unique_id to the hash
table we were not duplicating the unique ID. If we then added some information
(for example, the branch in refine) the unique ID would be marked as invalidated
which meant that it was automatically re-generated whenever it was needed again.
In the meantime, when we got hash table GHashFunc matches we would run the
GEqualFunc on the now-free'd memory area and fail to see that the keys were
indeed equal.
src/gs-app-list.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-app-list.c b/src/gs-app-list.c
index 349b4f4..2a5ebdd 100644
--- a/src/gs-app-list.c
+++ b/src/gs-app-list.c
@@ -100,7 +100,7 @@ gs_app_list_add_safe (GsAppList *list, GsApp *app)
/* just use the ref */
g_ptr_array_add (list->array, g_object_ref (app));
- g_hash_table_insert (list->hash_by_id, (gpointer) id, (gpointer) app);
+ g_hash_table_insert (list->hash_by_id, g_strdup (id), g_object_ref (app));
}
/**
@@ -432,8 +432,10 @@ gs_app_list_init (GsAppList *list)
g_mutex_init (&list->mutex);
list->array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
#if AS_CHECK_VERSION(0,6,2)
- list->hash_by_id = g_hash_table_new ((GHashFunc) as_utils_unique_id_hash,
- (GEqualFunc) as_utils_unique_id_equal);
+ list->hash_by_id = g_hash_table_new_full ((GHashFunc) as_utils_unique_id_hash,
+ (GEqualFunc) as_utils_unique_id_equal,
+ g_free,
+ (GDestroyNotify) g_object_unref);
#else
list->hash_by_id = g_hash_table_new (g_str_hash, g_str_equal);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]