Merge lp:~ted/libdbusmenu/dbus-error-handling into lp:libdbusmenu/0.5

Proposed by Ted Gould
Status: Merged
Merged at revision: not available
Proposed branch: lp:~ted/libdbusmenu/dbus-error-handling
Merge into: lp:libdbusmenu/0.5
Diff against target: 116 lines (+27/-12)
3 files modified
libdbusmenu-glib/client.c (+24/-9)
libdbusmenu-glib/server-marshal.list (+1/-1)
libdbusmenu-glib/server.c (+2/-2)
To merge this branch: bzr merge lp:~ted/libdbusmenu/dbus-error-handling
Reviewer Review Type Date Requested Status
Cody Russell (community) Approve
Review via email: mp+18949@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

Changing callbacks from DBus to be more protected in cases of errors.
Also changing a prototype that was wrong when compared to the
dbus-menu.xml spec.

Revision history for this message
Cody Russell (bratsche) :
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 2010-02-08 22:02:12 +0000
3+++ libdbusmenu-glib/client.c 2010-02-09 19:55:18 +0000
4@@ -96,7 +96,7 @@
5 static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec);
6 static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec);
7 /* Private Funcs */
8-static void layout_update (DBusGProxy * proxy, gint revision, guint parent, DbusmenuClient * client);
9+static void layout_update (DBusGProxy * proxy, guint revision, gint parent, DbusmenuClient * client);
10 static void id_prop_update (DBusGProxy * proxy, gint id, gchar * property, GValue * value, DbusmenuClient * client);
11 static void id_update (DBusGProxy * proxy, gint id, DbusmenuClient * client);
12 static void build_proxies (DbusmenuClient * client);
13@@ -309,7 +309,7 @@
14
15 /* Annoying little wrapper to make the right function update */
16 static void
17-layout_update (DBusGProxy * proxy, gint revision, guint parent, DbusmenuClient * client)
18+layout_update (DBusGProxy * proxy, guint revision, gint parent, DbusmenuClient * client)
19 {
20 DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);
21 priv->current_revision = revision;
22@@ -504,8 +504,8 @@
23 dbus_g_proxy_add_signal(priv->menuproxy, "LayoutUpdated", G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID);
24 dbus_g_proxy_connect_signal(priv->menuproxy, "LayoutUpdated", G_CALLBACK(layout_update), client, NULL);
25
26- dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__UINT_STRING_POINTER, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
27- dbus_g_proxy_add_signal(priv->menuproxy, "ItemPropertyUpdated", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
28+ dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__INT_STRING_POINTER, G_TYPE_NONE, G_TYPE_INT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
29+ dbus_g_proxy_add_signal(priv->menuproxy, "ItemPropertyUpdated", G_TYPE_INT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID);
30 dbus_g_proxy_connect_signal(priv->menuproxy, "ItemPropertyUpdated", G_CALLBACK(id_prop_update), client, NULL);
31
32 dbus_g_proxy_add_signal(priv->menuproxy, "ItemUpdated", G_TYPE_INT, G_TYPE_INVALID);
33@@ -561,6 +561,7 @@
34 static void
35 menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data)
36 {
37+ g_return_if_fail(DBUSMENU_IS_MENUITEM(data));
38 if (error != NULL) {
39 g_warning("Error getting properties on a menuitem: %s", error->message);
40 return;
41@@ -570,19 +571,33 @@
42 return;
43 }
44
45+/* This function is called to refresh the properites on an item that
46+ is getting recycled with the update, but we think might have prop
47+ changes. */
48 static void
49 menuitem_get_properties_replace_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data)
50 {
51+ g_return_if_fail(DBUSMENU_IS_MENUITEM(data));
52+ gboolean have_error = FALSE;
53+
54+ if (error != NULL) {
55+ g_warning("Unable to replace properties on %d: %s", dbusmenu_menuitem_get_id(DBUSMENU_MENUITEM(data)), error->message);
56+ have_error = TRUE;
57+ }
58+
59 GList * current_props = NULL;
60
61 for (current_props = dbusmenu_menuitem_properties_list(DBUSMENU_MENUITEM(data));
62 current_props != NULL ; current_props = g_list_next(current_props)) {
63- if (g_hash_table_lookup(properties, current_props->data) == NULL) {
64+ if (have_error || g_hash_table_lookup(properties, current_props->data) == NULL) {
65 dbusmenu_menuitem_property_remove(DBUSMENU_MENUITEM(data), (const gchar *)current_props->data);
66 }
67 }
68
69- menuitem_get_properties_cb(proxy, properties, error, data);
70+ if (!have_error) {
71+ menuitem_get_properties_cb(proxy, properties, error, data);
72+ }
73+
74 return;
75 }
76
77@@ -632,13 +647,13 @@
78 return;
79 }
80
81+/* Respond to the call function to make sure that the other side
82+ got it, or print a warning. */
83 static void
84 menuitem_call_cb (DBusGProxy * proxy, GError * error, gpointer userdata)
85 {
86- DbusmenuMenuitem * mi = (DbusmenuMenuitem *)userdata;
87-
88 if (error != NULL) {
89- g_warning("Unable to call menu item %d: %s", dbusmenu_menuitem_get_id(mi), error->message);
90+ g_warning("Unable to call menu item %d: %s", GPOINTER_TO_INT(userdata), error->message);
91 }
92
93 return;
94
95=== modified file 'libdbusmenu-glib/server-marshal.list'
96--- libdbusmenu-glib/server-marshal.list 2010-02-03 18:33:58 +0000
97+++ libdbusmenu-glib/server-marshal.list 2010-02-09 19:55:18 +0000
98@@ -1,2 +1,2 @@
99-VOID: UINT, STRING, POINTER
100+VOID: INT, STRING, POINTER
101 VOID: UINT, INT
102
103=== modified file 'libdbusmenu-glib/server.c'
104--- libdbusmenu-glib/server.c 2010-02-05 05:17:32 +0000
105+++ libdbusmenu-glib/server.c 2010-02-09 19:55:18 +0000
106@@ -129,8 +129,8 @@
107 G_SIGNAL_RUN_LAST,
108 G_STRUCT_OFFSET(DbusmenuServerClass, id_prop_update),
109 NULL, NULL,
110- _dbusmenu_server_marshal_VOID__UINT_STRING_POINTER,
111- G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE);
112+ _dbusmenu_server_marshal_VOID__INT_STRING_POINTER,
113+ G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_VALUE);
114 /**
115 DbusmenuServer::id-update:
116 @arg0: The #DbusmenuServer emitting the signal.

Subscribers

People subscribed via source and target branches