diff options
author | Ted Gould <ted@gould.cx> | 2010-07-02 09:49:19 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-07-02 09:49:19 -0500 |
commit | 542dbbe2852405263e440a4be6bc6210e8abb49a (patch) | |
tree | 719b1a674d90c1dc059fa8b61f1bbd139722a18d /libdbusmenu-glib | |
parent | 235abfa96562b5ba4d1876dc99e86551160ee34c (diff) | |
parent | 26d44b572f237f592862333d6dbb9d8899259bca (diff) | |
download | libdbusmenu-542dbbe2852405263e440a4be6bc6210e8abb49a.tar.gz libdbusmenu-542dbbe2852405263e440a4be6bc6210e8abb49a.tar.bz2 libdbusmenu-542dbbe2852405263e440a4be6bc6210e8abb49a.zip |
Handle not having a session bus better.
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r-- | libdbusmenu-glib/server.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 0da66cc..13c2843 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -225,15 +225,22 @@ static void 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) { |