Merge lp:~ted/libdbusmenu/lp730925 into lp:libdbusmenu/0.5

Proposed by Ted Gould
Status: Merged
Merged at revision: 281
Proposed branch: lp:~ted/libdbusmenu/lp730925
Merge into: lp:libdbusmenu/0.5
Diff against target: 34 lines (+21/-0)
1 file modified
libdbusmenu-glib/client.c (+21/-0)
To merge this branch: bzr merge lp:~ted/libdbusmenu/lp730925
Reviewer Review Type Date Requested Status
Conor Curran (community) Approve
Review via email: mp+54421@code.launchpad.net

Description of the change

Making sure that properties that are getting updated don't recieved a removed signal before the update.

To post a comment you must log in.
lp:~ted/libdbusmenu/lp730925 updated
281. By Ted Gould

Protect against NULL properties

Revision history for this message
Conor Curran (cjcurran) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libdbusmenu-glib/client.c'
2--- libdbusmenu-glib/client.c 2011-03-14 19:30:23 +0000
3+++ libdbusmenu-glib/client.c 2011-03-22 21:23:30 +0000
4@@ -1368,9 +1368,30 @@
5 have_error = TRUE;
6 }
7
8+ /* Get the list of the current properties */
9 GList * current_props = dbusmenu_menuitem_properties_list(DBUSMENU_MENUITEM(data));
10 GList * tmp = NULL;
11
12+ if (properties != NULL) {
13+ GVariantIter iter;
14+ g_variant_iter_init(&iter, properties);
15+ gchar * name; GVariant * value;
16+
17+ /* Remove the entries from the current list that we have new
18+ values for. This way we don't create signals of them being
19+ removed with the duplication of the value being changed. */
20+ while (g_variant_iter_loop(&iter, "{sv}", &name, &value) && have_error == FALSE) {
21+ for (tmp = current_props; tmp != NULL; tmp = g_list_next(tmp)) {
22+ if (g_strcmp0((gchar *)tmp->data, name) == 0) {
23+ current_props = g_list_delete_link(current_props, tmp);
24+ break;
25+ }
26+ }
27+ }
28+ }
29+
30+ /* Remove all entries that we're not getting values for, we can
31+ assume that they no longer exist */
32 for (tmp = current_props; tmp != NULL && have_error == FALSE; tmp = g_list_next(tmp)) {
33 dbusmenu_menuitem_property_remove(DBUSMENU_MENUITEM(data), (const gchar *)tmp->data);
34 }

Subscribers

People subscribed via source and target branches