Bug 767178 - Segment fault on deleting an automatic folder tag

The GimpTaggedContainer->tag_ref_counts keeps pointers to GimpTags but
didn't ref them. Ref the tags while they are in the hash table.
This commit is contained in:
Michael Natterer 2016-09-27 10:14:45 +02:00
parent 75853eec01
commit 81603eaa58
1 changed files with 9 additions and 4 deletions

View File

@ -112,8 +112,10 @@ static void
gimp_tagged_container_init (GimpTaggedContainer *tagged_container)
{
tagged_container->tag_ref_counts =
g_hash_table_new ((GHashFunc) gimp_tag_get_hash,
(GEqualFunc) gimp_tag_equals);
g_hash_table_new_full ((GHashFunc) gimp_tag_get_hash,
(GEqualFunc) gimp_tag_equals,
(GDestroyNotify) g_object_unref,
(GDestroyNotify) NULL);
}
static void
@ -418,7 +420,9 @@ gimp_tagged_container_ref_tag (GimpTaggedContainer *tagged_container,
tag));
ref_count++;
g_hash_table_insert (tagged_container->tag_ref_counts,
tag, GINT_TO_POINTER (ref_count));
g_object_ref (tag),
GINT_TO_POINTER (ref_count));
if (ref_count == 1)
{
tagged_container->tag_count++;
@ -441,7 +445,8 @@ gimp_tagged_container_unref_tag (GimpTaggedContainer *tagged_container,
if (ref_count > 0)
{
g_hash_table_insert (tagged_container->tag_ref_counts,
tag, GINT_TO_POINTER (ref_count));
g_object_ref (tag),
GINT_TO_POINTER (ref_count));
}
else
{