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

Proposed by Ted Gould
Status: Merged
Merged at revision: 280
Proposed branch: lp:~ted/libdbusmenu/lp739476
Merge into: lp:libdbusmenu/0.5
Diff against target: 126 lines (+19/-25)
1 file modified
libdbusmenu-glib/client.c (+19/-25)
To merge this branch: bzr merge lp:~ted/libdbusmenu/lp739476
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen (community) Approve
Review via email: mp+54240@code.launchpad.net

Description of the change

Removing the unref to just use iter_loop. Also, switching to init some iters intead of newing them to make the code a little bit cleaner.

To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Looks fine and dandy to me :-)

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-21 17:16:31 +0000
4@@ -599,9 +599,10 @@
5
6 /* Callback all the folks we can find */
7 GVariant * child = g_variant_get_child_value(params, 0);
8- GVariantIter * iter = g_variant_iter_new(child);
9+ GVariantIter iter;
10+ g_variant_iter_init(&iter, child);
11 g_variant_unref(child);
12- while ((child = g_variant_iter_next_value(iter)) != NULL) {
13+ while ((child = g_variant_iter_next_value(&iter)) != NULL) {
14 if (g_strcmp0(g_variant_get_type_string(child), "(ia{sv})") != 0) {
15 g_warning("Properties return signature is not '(ia{sv})' it is '%s'", g_variant_get_type_string(child));
16 g_variant_unref(child);
17@@ -631,7 +632,6 @@
18 g_variant_unref(properties);
19 g_variant_unref(child);
20 }
21- g_variant_iter_free(iter);
22 g_variant_unref(params);
23
24 /* Provide errors for those who we can't */
25@@ -1153,7 +1153,7 @@
26 GVariantIter iters;
27 gchar * key; GVariant * value;
28 g_variant_iter_init(&iters, properties);
29- while (g_variant_iter_next(&iters, "{sv}", &key, &value)) {
30+ while (g_variant_iter_loop(&iters, "{sv}", &key, &value)) {
31 if (g_strcmp0(key, "TextDirection") == 0) {
32 if (g_variant_is_of_type(value, G_VARIANT_TYPE_VARIANT)) {
33 GVariant * tmp = g_variant_get_variant(value);
34@@ -1181,9 +1181,6 @@
35 priv->icon_dirs = g_variant_dup_strv(value, NULL);
36 dirs_changed = TRUE;
37 }
38-
39- g_variant_unref(value);
40- g_free(key);
41 }
42
43 if (olddir != priv->text_direction) {
44@@ -1258,10 +1255,9 @@
45 g_variant_iter_init(&properties, propv);
46 gchar * property;
47
48- while (g_variant_iter_next(&properties, "s", &property)) {
49+ while (g_variant_iter_loop(&properties, "s", &property)) {
50 /* g_debug("Removing property '%s' on %d", property, id); */
51 dbusmenu_menuitem_property_remove(menuitem, property);
52- g_free(property);
53 }
54 g_variant_unref(ritem);
55 g_variant_unref(propv);
56@@ -1284,15 +1280,20 @@
57 gchar * property;
58 GVariant * value;
59
60- while (g_variant_iter_next(&properties, "{sv}", &property, &value)) {
61+ while (g_variant_iter_loop(&properties, "{sv}", &property, &value)) {
62 GVariant * internalvalue = value;
63 if (G_LIKELY(g_variant_is_of_type(value, G_VARIANT_TYPE_VARIANT))) {
64 /* Unboxing if needed */
65 internalvalue = g_variant_get_variant(value);
66- g_variant_unref(value);
67 }
68+
69 id_prop_update(proxy, id, property, internalvalue, client);
70- g_variant_unref(internalvalue);
71+
72+ if (internalvalue != value) {
73+ /* If we unboxed, we need to drop it, otherwise the
74+ iter_loop function will unref for us */
75+ g_variant_unref(internalvalue);
76+ }
77 }
78 g_variant_unref(propv);
79 g_variant_unref(item);
80@@ -1336,19 +1337,16 @@
81 return;
82 }
83
84- GVariantIter * iter = g_variant_iter_new(properties);
85+ GVariantIter iter;
86 gchar * key;
87 GVariant * value;
88
89- while (g_variant_iter_next(iter, "{sv}", &key, &value)) {
90+ g_variant_iter_init(&iter, properties);
91+
92+ while (g_variant_iter_loop(&iter, "{sv}", &key, &value)) {
93 dbusmenu_menuitem_property_set_variant(item, key, value);
94-
95- g_variant_unref(value);
96- g_free(key);
97 }
98
99- g_variant_iter_free(iter);
100-
101 g_object_unref(data);
102
103 return;
104@@ -1714,20 +1712,16 @@
105 all other properties. */
106 child_props = g_variant_get_child_value(child, 1);
107 g_variant_iter_init(&iter, child_props);
108- while (g_variant_iter_next(&iter, "{sv}", &prop, &value)) {
109+ while (g_variant_iter_loop(&iter, "{sv}", &prop, &value)) {
110 if (g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TYPE) == 0) {
111 dbusmenu_menuitem_property_set_variant(childmi, prop, value);
112 }
113- g_free(prop);
114- g_variant_unref(value);
115 }
116
117 /* Now go through and do all the properties. */
118 g_variant_iter_init(&iter, child_props);
119- while (g_variant_iter_next(&iter, "{sv}", &prop, &value)) {
120+ while (g_variant_iter_loop(&iter, "{sv}", &prop, &value)) {
121 dbusmenu_menuitem_property_set_variant(childmi, prop, value);
122- g_free(prop);
123- g_variant_unref(value);
124 }
125 g_variant_unref(child_props);
126 }

Subscribers

People subscribed via source and target branches