diff options
author | Ted Gould <ted@gould.cx> | 2011-02-21 21:17:29 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2011-02-21 21:17:29 -0600 |
commit | db5438c7f8721ca3b32df9be5b3cd980aebc6784 (patch) | |
tree | 743cb4a755f7fa63b5a5c424011a8701e0a02524 /libdbusmenu-glib | |
parent | 32f2fccc8b40dc5ccea70acff83a5b6f0302ffea (diff) | |
download | libdbusmenu-db5438c7f8721ca3b32df9be5b3cd980aebc6784.tar.gz libdbusmenu-db5438c7f8721ca3b32df9be5b3cd980aebc6784.tar.bz2 libdbusmenu-db5438c7f8721ca3b32df9be5b3cd980aebc6784.zip |
Always replace to ensure we don't leak references.
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r-- | libdbusmenu-glib/menuitem.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index a773755..2e3b8f0 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1054,13 +1054,18 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro gpointer currentval = g_hash_table_lookup(priv->properties, property); if (value != NULL) { - gchar * lprop = g_strdup(property); - g_variant_ref_sink(value); - + /* NOTE: We're only marking this as replaced if this is true + but we're actually replacing it no matter. This is so that + the variant passed in sticks around which the caller may + expect. They shouldn't, but it's low cost to remove bugs. */ if (currentval == NULL || !g_variant_equal((GVariant*)currentval, value)) { - g_hash_table_replace(priv->properties, lprop, value); replaced = TRUE; } + + gchar * lprop = g_strdup(property); + g_variant_ref_sink(value); + + g_hash_table_replace(priv->properties, lprop, value); } else { if (currentval != NULL) { g_hash_table_remove(priv->properties, property); |