[gnome-software/wip/hughsie/vnd.flatpak.ref: 10/12] Fix weirdness when de-duplicating applications
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/vnd.flatpak.ref: 10/12] Fix weirdness when de-duplicating applications
- Date: Tue, 20 Sep 2016 13:36:39 +0000 (UTC)
commit ede5cf61ca08df05b165c538b2e76c1e9c429298
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 1c71782..d66bc14 100644
--- a/src/gs-app-list.c
+++ b/src/gs-app-list.c
@@ -118,7 +118,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));
}
/**
@@ -449,8 +449,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);
- 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);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]