diff options
author | Ted Gould <ted@gould.cx> | 2011-01-21 13:27:26 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2011-01-21 13:27:26 -0600 |
commit | 48e68b4411e70f0526fca90d3d714f10aea566bb (patch) | |
tree | d2d003801dbd8f5bfac86021f410fe4e07ecdab2 | |
parent | 4bb9903a560f83b1b8a19c7801efab80d677ab46 (diff) | |
download | libdbusmenu-48e68b4411e70f0526fca90d3d714f10aea566bb.tar.gz libdbusmenu-48e68b4411e70f0526fca90d3d714f10aea566bb.tar.bz2 libdbusmenu-48e68b4411e70f0526fca90d3d714f10aea566bb.zip |
Making the hashtable have a full copy and free itself appropriately.
-rw-r--r-- | libdbusmenu-glib/menuitem.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 827d6c5..b40195c 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1204,11 +1204,17 @@ dbusmenu_menuitem_properties_list (DbusmenuMenuitem * mi) return g_hash_table_get_keys(priv->properties); } +/* Copy the keys and make references to the variants that are + in the new table. They'll be free'd and unref'd when the + Hashtable gets destroyed. */ static void copy_helper (gpointer in_key, gpointer in_value, gpointer in_data) { GHashTable * table = (GHashTable *)in_data; - g_hash_table_insert(table, in_key, in_value); + gchar * key = (gchar *)in_key; + GVariant * value = (GVariant *)in_value; + g_variant_ref(value); + g_hash_table_insert(table, g_strdup(key), value); return; } @@ -1229,7 +1235,7 @@ copy_helper (gpointer in_key, gpointer in_value, gpointer in_data) GHashTable * dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi) { - GHashTable * ret = g_hash_table_new(g_str_hash, g_str_equal); + GHashTable * ret = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, _g_variant_unref); g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), ret); |