Commit c3125ee3 authored by Allison Karlitskaya's avatar Allison Karlitskaya

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
parent 19089104
......@@ -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;
}
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment