From 969c97426a868626e8c6289e3a7ff3207fc56624 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 20 May 2014 13:25:17 +0100 Subject: Do not print a critical warning when misusing up_device_set_object_path_sync() --- libupower-glib/up-device.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libupower-glib/up-device.c b/libupower-glib/up-device.c index 2d65806..9f6e0e1 100644 --- a/libupower-glib/up-device.c +++ b/libupower-glib/up-device.c @@ -125,6 +125,7 @@ gboolean up_device_set_object_path_sync (UpDevice *device, const gchar *object_path, GCancellable *cancellable, GError **error) { UpDeviceGlue *proxy_device; + gboolean ret = TRUE; g_return_val_if_fail (UP_IS_DEVICE (device), FALSE); g_return_val_if_fail (object_path != NULL, FALSE); @@ -132,6 +133,14 @@ up_device_set_object_path_sync (UpDevice *device, const gchar *object_path, GCan if (device->priv->proxy_device != NULL) return FALSE; + /* check valid */ + if (!g_variant_is_object_path (object_path)) { + ret = FALSE; + g_set_error (error, 1, 0, + "Object path invalid: %s", object_path); + goto out; + } + g_clear_pointer (&device->priv->offline_props, g_hash_table_unref); /* connect to the correct path for all the other methods */ @@ -150,8 +159,8 @@ up_device_set_object_path_sync (UpDevice *device, const gchar *object_path, GCan /* yay */ device->priv->proxy_device = proxy_device; - - return TRUE; +out: + return ret; } /** -- cgit v1.2.1