aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib/menuitem.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-03-07 10:46:22 -0600
committerTed Gould <ted@gould.cx>2011-03-07 10:46:22 -0600
commit639d982ed6fb70b09cd72e19a73d16a5e2f78db3 (patch)
tree67036970b62524d411d1394f73c17a3955ef807b /libdbusmenu-glib/menuitem.c
parent1a1e6c4c24276b7d921d729c277e0c2fd7405d40 (diff)
downloadlibdbusmenu-639d982ed6fb70b09cd72e19a73d16a5e2f78db3.tar.gz
libdbusmenu-639d982ed6fb70b09cd72e19a73d16a5e2f78db3.tar.bz2
libdbusmenu-639d982ed6fb70b09cd72e19a73d16a5e2f78db3.zip
Switching to using the extended lookup and getting the key and value
Diffstat (limited to 'libdbusmenu-glib/menuitem.c')
-rw-r--r--libdbusmenu-glib/menuitem.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c
index f7867e4..8534370 100644
--- a/libdbusmenu-glib/menuitem.c
+++ b/libdbusmenu-glib/menuitem.c
@@ -1183,14 +1183,16 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro
gboolean replaced = FALSE;
gboolean remove = FALSE;
- gpointer currentval = g_hash_table_lookup(priv->properties, property);
+ gchar * hash_key = NULL;
+ GVariant * hash_variant = NULL;
+ gboolean inhash = g_hash_table_lookup_extended(priv->properties, property, (gpointer *)&hash_key, (gpointer *)&hash_variant);
if (value != NULL) {
/* 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)) {
+ if (inhash || !g_variant_equal(hash_variant, value)) {
replaced = TRUE;
}
@@ -1204,7 +1206,7 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro
bad value */
g_hash_table_insert(priv->properties, lprop, value);
} else {
- if (currentval != NULL) {
+ if (inhash) {
/* So the question you should be asking if you're paying attention
is "Why not just do the remove here?" It's a good question with
an interesting answer. Bascially it's the same reason as above,
@@ -1220,7 +1222,7 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro
becuse it has been unref'd when replaced in the hash
table. But the fact that there was a value is
the imporant part. */
- if (currentval == NULL || replaced) {
+ if (!inhash || replaced) {
GVariant * signalval = value;
if (signalval == NULL) {