← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~ted/dbusmenu/handle-no-bus into lp:dbusmenu

 

Ted Gould has proposed merging lp:~ted/dbusmenu/handle-no-bus into lp:dbusmenu.

Requested reviews:
  DBus Menu Team (dbusmenu-team)
Related bugs:
  #598715 WoW Model Viewer crashes on start (wxGTK application)
  https://bugs.launchpad.net/bugs/598715


Check for session bus before registering the object on it.
-- 
https://code.launchpad.net/~ted/dbusmenu/handle-no-bus/+merge/29087
Your team ayatana-commits is subscribed to branch lp:dbusmenu.
=== modified file 'libdbusmenu-glib/server.c'
--- libdbusmenu-glib/server.c	2010-05-27 14:44:35 +0000
+++ libdbusmenu-glib/server.c	2010-07-02 14:01:39 +0000
@@ -225,15 +225,22 @@
 set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec)
 {
 	DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(obj);
+	GError * error = NULL;
 
 	switch (id) {
 	case PROP_DBUS_OBJECT:
 		g_return_if_fail(priv->dbusobject == NULL);
 		priv->dbusobject = g_value_dup_string(value);
-		DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
-		dbus_g_connection_register_g_object(connection,
-											priv->dbusobject,
-											obj);
+		DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
+
+		if (connection == NULL || error != NULL) {
+			g_warning("Unable to get session bus: %s", error == NULL ? "No message" : error->message);
+			if (error != NULL) { g_error_free(error); }
+		} else {
+			dbus_g_connection_register_g_object(connection,
+			                                    priv->dbusobject,
+			                                    obj);
+		}
 		break;
 	case PROP_ROOT_NODE:
 		if (priv->root != NULL) {


Follow ups