diff options
author | Ted Gould <ted@gould.cx> | 2011-03-22 14:55:33 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2011-03-22 14:55:33 -0500 |
commit | 8bab6b9d433d5cfd0d03c303e9d3e6bdc14a035d (patch) | |
tree | 08415b5d3d9c953f379ecd147c5372e36ef30392 /libdbusmenu-glib | |
parent | 746a792ef912c5160fed15bf817df5124f6610b0 (diff) | |
download | libdbusmenu-8bab6b9d433d5cfd0d03c303e9d3e6bdc14a035d.tar.gz libdbusmenu-8bab6b9d433d5cfd0d03c303e9d3e6bdc14a035d.tar.bz2 libdbusmenu-8bab6b9d433d5cfd0d03c303e9d3e6bdc14a035d.zip |
Protect the entries that are about to be updated from being removed
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r-- | libdbusmenu-glib/client.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 2976436..018508c 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1368,9 +1368,28 @@ menuitem_get_properties_replace_cb (GVariant * properties, GError * error, gpoin have_error = TRUE; } + /* Get the list of the current properties */ GList * current_props = dbusmenu_menuitem_properties_list(DBUSMENU_MENUITEM(data)); GList * tmp = NULL; + GVariantIter iter; + g_variant_iter_init(&iter, properties); + gchar * name; GVariant * value; + + /* Remove the entries from the current list that we have new + values for. This way we don't create signals of them being + removed with the duplication of the value being changed. */ + while (g_variant_iter_loop(&iter, "{sv}", &name, &value) && have_error == FALSE) { + for (tmp = current_props; tmp != NULL; tmp = g_list_next(tmp)) { + if (g_strcmp0((gchar *)tmp->data, name) == 0) { + current_props = g_list_remove(current_props, tmp); + break; + } + } + } + + /* Remove all entries that we're not getting values for, we can + assume that they no longer exist */ for (tmp = current_props; tmp != NULL && have_error == FALSE; tmp = g_list_next(tmp)) { dbusmenu_menuitem_property_remove(DBUSMENU_MENUITEM(data), (const gchar *)tmp->data); } |