gobject: Don't leak pspecs for ininstantiated interfaces

Remove the awkward ownerhsip of pspec by the object. pspecs are
now only owned by the pool, which makes things more predictable.

https://bugzilla.gnome.org/show_bug.cgi?id=711778
This commit is contained in:
Stef Walter
2013-11-08 08:45:41 +01:00
parent 806868941d
commit faa42f57f1
2 changed files with 6 additions and 7 deletions

View File

@@ -436,9 +436,8 @@ _g_object_type_free_pspecs (GType type)
{
GParamSpec *pspec = node->data;
g_param_spec_pool_remove (pspec_pool, pspec);
PARAM_SPEC_SET_PARAM_ID (pspec, 0);
g_param_spec_unref (pspec);
g_param_spec_pool_remove (pspec_pool, pspec);
}
g_list_free (list);
}
@@ -533,6 +532,7 @@ install_property_internal (GType g_type,
g_param_spec_ref_sink (pspec);
PARAM_SPEC_SET_PARAM_ID (pspec, property_id);
g_param_spec_pool_insert (pspec_pool, pspec, g_type);
g_param_spec_unref (pspec);
}
/**

View File

@@ -917,7 +917,8 @@ g_param_spec_pool_new (gboolean type_prefixing)
memcpy (&pool->mutex, &init_mutex, sizeof (init_mutex));
pool->type_prefixing = type_prefixing != FALSE;
pool->hash_table = g_hash_table_new (param_spec_pool_hash, param_spec_pool_equals);
pool->hash_table = g_hash_table_new_full (param_spec_pool_hash, param_spec_pool_equals,
NULL, (GDestroyNotify)g_param_spec_unref);
return pool;
}
@@ -957,7 +958,7 @@ g_param_spec_pool_insert (GParamSpecPool *pool,
g_mutex_lock (&pool->mutex);
pspec->owner_type = owner_type;
g_param_spec_ref (pspec);
g_hash_table_insert (pool->hash_table, pspec, pspec);
g_hash_table_add (pool->hash_table, pspec);
g_mutex_unlock (&pool->mutex);
}
else
@@ -983,9 +984,7 @@ g_param_spec_pool_remove (GParamSpecPool *pool,
if (pool && pspec)
{
g_mutex_lock (&pool->mutex);
if (g_hash_table_remove (pool->hash_table, pspec))
g_param_spec_unref (pspec);
else
if (!g_hash_table_remove (pool->hash_table, pspec))
g_warning (G_STRLOC ": attempt to remove unknown pspec '%s' from pool", pspec->name);
g_mutex_unlock (&pool->mutex);
}