+ * Check that the finalization code works
+ *
+ * (and that the GDestroyNotify for filters and objects and signal
+ * registrations are run as expected)
+ */
+ error = NULL;
+ c2 = _g_bus_get_priv (G_BUS_TYPE_SESSION, NULL, &error);
+ g_assert_no_error (error);
+ g_assert (c2 != NULL);
+ /* signal registration */
+ on_signal_registration_freed_called = FALSE;
+ g_dbus_connection_signal_subscribe (c2,
+ "org.freedesktop.DBus", /* bus name */
+ "org.freedesktop.DBus", /* interface */
+ "NameOwnerChanged", /* member */
+ "/org/freesktop/DBus", /* path */
+ NULL, /* arg0 */
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ on_name_owner_changed,
+ &on_signal_registration_freed_called,
+ a_gdestroynotify_that_sets_a_gboolean_to_true_and_quits_loop);
+ /* filter func */
+ on_filter_freed_called = FALSE;
+ g_dbus_connection_add_filter (c2,
+ some_filter_func,
+ &on_filter_freed_called,
+ a_gdestroynotify_that_sets_a_gboolean_to_true_and_quits_loop);
+ /* object registration */
+ on_register_object_freed_called = FALSE;
+ error = NULL;
+ registration_id = g_dbus_connection_register_object (c2,
+ "/foo",
+ (GDBusInterfaceInfo *) &boo_interface_info,
+ &boo_vtable,
+ &on_register_object_freed_called,
+ a_gdestroynotify_that_sets_a_gboolean_to_true_and_quits_loop,
+ &error);
+ g_assert_no_error (error);
+ g_assert (registration_id > 0);
+ /* ok, finalize the connection and check that all the GDestroyNotify functions are invoked as expected */
+ g_object_unref (c2);
+ quit_mainloop_fired = FALSE;
+ quit_mainloop_id = g_timeout_add (1000, test_connection_quit_mainloop, &quit_mainloop_fired);
+ while (TRUE)
+ {
+ if (on_signal_registration_freed_called &&
+ on_filter_freed_called &&
+ on_register_object_freed_called)
+ break;
+ if (quit_mainloop_fired)
+ break;
+ g_main_loop_run (loop);
+ }
+ g_source_remove (quit_mainloop_id);
+ g_assert (on_signal_registration_freed_called);
+ g_assert (on_filter_freed_called);
+ g_assert (on_register_object_freed_called);
+ g_assert (!quit_mainloop_fired);
+
+ /*