From 1951c39c44afad8273e2978b4c1420e975882934 Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Wed, 9 Jun 2010 10:56:35 -0400 Subject: [PATCH] =?UTF-8?q?Bug=20621119=20=E2=80=93=20GDBusProxy=20and=20o?= =?UTF-8?q?bjects=20with=20no=20properties?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix proxy construction for objects with no properties in the case where G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES isn't set. The unfortunate side-effect here is that GDBusProxy can no longer be used to test for "object existence", e.g. creating a GDBusProxy for any path and interface will not fail. But that's not really a big deal, if apps rely on that they are doing something very wrong. https://bugzilla.gnome.org/show_bug.cgi?id=621119 Signed-off-by: David Zeuthen --- gio/gdbusproxy.c | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/gio/gdbusproxy.c b/gio/gdbusproxy.c index 8be309f0b..b4a64121c 100644 --- a/gio/gdbusproxy.c +++ b/gio/gdbusproxy.c @@ -851,7 +851,22 @@ initable_init (GInitable *initable, cancellable, error); if (result == NULL) - goto out; + { + /* We just ignore if GetAll() is failing. Because this might happen + * if the object has no properties at all. Or if the caller is + * not authorized to see the properties. + * + * Either way, apps can know about this by using + * get_cached_property_names() or get_cached_property(). + * + * TODO: handle G_DBUS_DEBUG flag 'proxy' and, if enabled, log the + * fact that GetAll() failed + */ + //g_debug ("error: %d %d %s", error->domain, error->code, error->message); + g_error_free (error); + ret = TRUE; + goto out; + } process_get_all_reply (proxy, result); @@ -888,7 +903,17 @@ get_all_cb (GDBusConnection *connection, &error); if (result == NULL) { - g_simple_async_result_set_from_error (simple, error); + /* We just ignore if GetAll() is failing. Because this might happen + * if the object has no properties at all. Or if the caller is + * not authorized to see the properties. + * + * Either way, apps can know about this by using + * get_cached_property_names() or get_cached_property(). + * + * TODO: handle G_DBUS_DEBUG flag 'proxy' and, if enabled, log the + * fact that GetAll() failed + */ + //g_debug ("error: %d %d %s", error->domain, error->code, error->message); g_error_free (error); } else @@ -954,16 +979,11 @@ async_initable_init_finish (GAsyncInitable *initable, ret = FALSE; + if (g_simple_async_result_propagate_error (simple, error)) + goto out; + result = g_simple_async_result_get_op_res_gpointer (simple); - if (result == NULL) - { - if (!(proxy->priv->flags & G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES)) - { - g_simple_async_result_propagate_error (simple, error); - goto out; - } - } - else + if (result != NULL) { process_get_all_reply (proxy, result); }