[evolution-data-server/openismus-work] tests: Avoid complaints about vanished peers



commit dc09e01e553e9fbcc2506e962875bfd92037d477
Author: Mathias Hasselmann <mathias openismus com>
Date:   Thu Feb 28 20:41:43 2013 +0100

    tests: Avoid complaints about vanished peers
    
    Tests failed when the DBus session ended early because of this warning from
    GDBus/ETestDBus: "g_dbus_connection_real_closed: Remote peer vanished with
    error: Underlying GIOStream returned 0 bytes on an async read
    (g-io-error-quark, 0). Exiting."

 tests/test-server-utils/e-test-dbus.c         |   10 ++++++----
 tests/test-server-utils/e-test-server-utils.c |    2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/tests/test-server-utils/e-test-dbus.c b/tests/test-server-utils/e-test-dbus.c
index 4d679aa..fe0b9f2 100644
--- a/tests/test-server-utils/e-test-dbus.c
+++ b/tests/test-server-utils/e-test-dbus.c
@@ -665,18 +665,20 @@ void
 e_test_dbus_down (ETestDBus *self)
 {
   GDBusConnection *connection = NULL;
+  gpointer weak_connection = NULL;
 
   g_return_if_fail (E_IS_TEST_DBUS (self));
   g_return_if_fail (self->priv->up);
 
-  /* connection = _g_bus_get_singleton_if_exists (G_BUS_TYPE_SESSION); */
-  /* if (connection != NULL) */
-  /*   g_dbus_connection_set_exit_on_close (connection, FALSE); */
+  connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+  g_dbus_connection_set_exit_on_close (connection, FALSE);
+  g_object_add_weak_pointer (G_OBJECT (connection), &weak_connection);
+  g_object_unref (connection);
 
   if (self->priv->bus_address != NULL)
     stop_daemon (self);
 
-  if (connection != NULL)
+  if (weak_connection)
     _g_object_unref_and_wait_weak_notify (connection);
 
   g_unsetenv ("DBUS_SESSION_BUS_ADDRESS");
diff --git a/tests/test-server-utils/e-test-server-utils.c b/tests/test-server-utils/e-test-server-utils.c
index 8c1a10d..4f8bf08 100644
--- a/tests/test-server-utils/e-test-server-utils.c
+++ b/tests/test-server-utils/e-test-server-utils.c
@@ -444,7 +444,7 @@ e_test_server_utils_run (void)
                 * in this case, presumably this is due to some leaked
                 * GDBusConnection reference counting
                 */
-               e_test_dbus_stop (global_test_dbus);
+               e_test_dbus_down (global_test_dbus);
                /* g_object_unref (global_test_dbus); */
                global_test_dbus = NULL;
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]