[glib] GDBusProxy: report an error instead of leaking it
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GDBusProxy: report an error instead of leaking it
- Date: Mon, 19 Mar 2012 16:41:33 +0000 (UTC)
commit c3125ee36d47e71d27906b88eed68b0b9c9b9e0c
Author: Ryan Lortie <desrt desrt ca>
Date: Fri Mar 16 13:15:46 2012 -0400
GDBusProxy: report an error instead of leaking it
GDBusProxy sets an error on a GSimpleAsyncResult and then returns
without dispatching the result for completion (and leaks the result in
the process). Fix that.
Also add a testcase. Unfortunately, adding the testcase uncovered
bug #672248. We can work around that by reordering the tests.
https://bugzilla.gnome.org/show_bug.cgi?id=672249
gio/gdbusproxy.c | 2 ++
gio/tests/gdbus-proxy.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 45 insertions(+), 1 deletions(-)
---
diff --git a/gio/gdbusproxy.c b/gio/gdbusproxy.c
index a7c56d1..398dcce 100644
--- a/gio/gdbusproxy.c
+++ b/gio/gdbusproxy.c
@@ -2727,6 +2727,8 @@ g_dbus_proxy_call_internal (GDBusProxy *proxy,
G_IO_ERROR,
G_IO_ERROR_FAILED,
_("Cannot invoke method; proxy is for a well-known name without an owner and proxy was constructed with the G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START flag"));
+ g_simple_async_result_complete_in_idle (simple);
+ g_object_unref (simple);
G_UNLOCK (properties_lock);
goto out;
}
diff --git a/gio/tests/gdbus-proxy.c b/gio/tests/gdbus-proxy.c
index 00e6274..ba750ff 100644
--- a/gio/tests/gdbus-proxy.c
+++ b/gio/tests/gdbus-proxy.c
@@ -836,6 +836,47 @@ test_no_properties (void)
g_object_unref (proxy);
}
+static gboolean
+fail_test (gpointer user_data)
+{
+ g_assert_not_reached ();
+}
+
+static void
+check_error (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GError *error = NULL;
+ GVariant *reply;
+
+ reply = g_dbus_proxy_call_finish (G_DBUS_PROXY (source), result, &error);
+ g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED);
+ g_assert (reply == NULL);
+ g_error_free (error);
+
+ g_main_loop_quit (loop);
+}
+
+static void
+test_wellknown_noauto (void)
+{
+ GError *error = NULL;
+ GDBusProxy *proxy;
+
+ proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
+ NULL, "some.name.that.does.not.exist",
+ "/", "some.interface", NULL, &error);
+ g_assert_no_error (error);
+ g_assert (proxy != NULL);
+
+ g_dbus_proxy_call (proxy, "method", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, check_error, NULL);
+ g_timeout_add (10000, fail_test, NULL);
+ g_main_loop_run (loop);
+ g_object_unref (proxy);
+}
+
int
main (int argc,
char *argv[])
@@ -860,8 +901,9 @@ main (int argc,
g_setenv ("DBUS_SESSION_BUS_ADDRESS", session_bus_get_temporary_address (), TRUE);
g_test_add_func ("/gdbus/proxy", test_proxy);
- g_test_add_func ("/gdbus/proxy/async", test_async);
g_test_add_func ("/gdbus/proxy/no-properties", test_no_properties);
+ g_test_add_func ("/gdbus/proxy/wellknown-noauto", test_wellknown_noauto);
+ g_test_add_func ("/gdbus/proxy/async", test_async);
ret = g_test_run();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]