aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib/menuitem.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-01-05 16:58:37 -0600
committerTed Gould <ted@gould.cx>2011-01-05 16:58:37 -0600
commita02639a8849df82b563331783f5d571622d65208 (patch)
tree025c50857c18fce3e3ecdd72f711b05c49d5e5eb /libdbusmenu-glib/menuitem.c
parent2597a9ea2a74a8390c0f46ea1518d493608aea19 (diff)
downloadlibdbusmenu-a02639a8849df82b563331783f5d571622d65208.tar.gz
libdbusmenu-a02639a8849df82b563331783f5d571622d65208.tar.bz2
libdbusmenu-a02639a8849df82b563331783f5d571622d65208.zip
Handling the case of a NULL variant by making it clear the hashtable of that property.
Diffstat (limited to 'libdbusmenu-glib/menuitem.c')
-rw-r--r--libdbusmenu-glib/menuitem.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c
index ad6472b..50354ee 100644
--- a/libdbusmenu-glib/menuitem.c
+++ b/libdbusmenu-glib/menuitem.c
@@ -984,14 +984,22 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro
DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
- gchar * lprop = g_strdup(property);
- g_variant_ref(value);
-
gboolean replaced = FALSE;
- gpointer currentval = g_hash_table_lookup(priv->properties, lprop);
- if (currentval == NULL || !g_variant_equal((GVariant*)currentval, value)) {
- g_hash_table_replace(priv->properties, lprop, value);
- replaced = TRUE;
+ gpointer currentval = g_hash_table_lookup(priv->properties, property);
+
+ if (value != NULL) {
+ gchar * lprop = g_strdup(property);
+ g_variant_ref(value);
+
+ if (currentval == NULL || !g_variant_equal((GVariant*)currentval, value)) {
+ g_hash_table_replace(priv->properties, lprop, value);
+ replaced = TRUE;
+ }
+ } else {
+ if (currentval != NULL) {
+ g_hash_table_remove(priv->properties, property);
+ replaced = TRUE;
+ }
}
/* NOTE: The actual value is invalid at this point
@@ -999,7 +1007,7 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro
table. But the fact that there was a value is
the imporant part. */
if (currentval == NULL || replaced) {
- g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, lprop, value, TRUE);
+ g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, property, value, TRUE);
}
return TRUE;