From af13be899572321d1c75ec8ecc42a19333801af0 Mon Sep 17 00:00:00 2001 From: Landry Breuil Date: Fri, 3 Apr 2015 13:53:13 +0200 Subject: [PATCH] Improve error handling when the systemwide dbus is not running. --- libupower-glib/up-client.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libupower-glib/up-client.c b/libupower-glib/up-client.c index 48d99a0..89ee235 100644 --- a/libupower-glib/up-client.c +++ b/libupower-glib/up-client.c @@ -96,6 +96,7 @@ up_client_get_devices (UpClient *client) g_return_val_if_fail (UP_IS_CLIENT (client), NULL); array = g_ptr_array_new (); + if (!UP_IS_CLIENT_GLUE (client->priv->proxy)) return array; if (up_client_glue_call_enumerate_devices_sync (client->priv->proxy, &devices, @@ -166,6 +167,7 @@ up_client_get_critical_action (UpClient *client) char *action; g_return_val_if_fail (UP_IS_CLIENT (client), NULL); + if (!UP_IS_CLIENT_GLUE (client->priv->proxy)) return NULL; if (!up_client_glue_call_get_critical_action_sync (client->priv->proxy, &action, NULL, NULL)) { @@ -188,6 +190,7 @@ const gchar * up_client_get_daemon_version (UpClient *client) { g_return_val_if_fail (UP_IS_CLIENT (client), NULL); + if (!UP_IS_CLIENT_GLUE (client->priv->proxy)) return NULL; return up_client_glue_get_daemon_version (client->priv->proxy); } @@ -205,6 +208,7 @@ gboolean up_client_get_lid_is_closed (UpClient *client) { g_return_val_if_fail (UP_IS_CLIENT (client), FALSE); + if (!UP_IS_CLIENT_GLUE (client->priv->proxy)) return FALSE; return up_client_glue_get_lid_is_closed (client->priv->proxy); } @@ -222,6 +226,7 @@ gboolean up_client_get_lid_is_present (UpClient *client) { g_return_val_if_fail (UP_IS_CLIENT (client), FALSE); + if (!UP_IS_CLIENT_GLUE (client->priv->proxy)) return FALSE; return up_client_glue_get_lid_is_present (client->priv->proxy); } @@ -239,6 +244,7 @@ gboolean up_client_get_on_battery (UpClient *client) { g_return_val_if_fail (UP_IS_CLIENT (client), FALSE); + if (!UP_IS_CLIENT_GLUE (client->priv->proxy)) return FALSE; return up_client_glue_get_on_battery (client->priv->proxy); } -- 2.3.4