From 8bab6b9d433d5cfd0d03c303e9d3e6bdc14a035d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Mar 2011 14:55:33 -0500 Subject: Protect the entries that are about to be updated from being removed --- libdbusmenu-glib/client.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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); } -- cgit v1.2.3 From a7c1e6c502cdc834617c59d157a3b787a5e8b0c7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Mar 2011 15:23:46 -0500 Subject: Remove the link instead of the data --- libdbusmenu-glib/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 018508c..825f3cb 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1382,7 +1382,7 @@ menuitem_get_properties_replace_cb (GVariant * properties, GError * error, gpoin 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); + current_props = g_list_delete_link(current_props, tmp); break; } } -- cgit v1.2.3 From f3616aa2137f519baf175649fafd2f83ae169830 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Mar 2011 16:22:22 -0500 Subject: Protect against NULL properties --- libdbusmenu-glib/client.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 825f3cb..fbf7621 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1372,18 +1372,20 @@ menuitem_get_properties_replace_cb (GVariant * properties, GError * error, gpoin 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_delete_link(current_props, tmp); - break; + if (properties != 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_delete_link(current_props, tmp); + break; + } } } } -- cgit v1.2.3