}
static void
+registry_weak_notify (gpointer data,
+ GObject *where_the_object_was)
+{
+ ETestServerFixture *fixture = (ETestServerFixture *)data;
+
+ fixture->registry_finalized = TRUE;
+}
+
+static void
+client_weak_notify (gpointer data,
+ GObject *where_the_object_was)
+{
+ ETestServerFixture *fixture = (ETestServerFixture *)data;
+
+ fixture->client_finalized = TRUE;
+}
+
+static void
e_test_server_utils_source_added (ESourceRegistry *registry,
ESource *source,
FixturePair *pair)
if (!pair->fixture->service.book_client)
g_error ("Unable to create the test book: %s", error->message);
+ g_object_weak_ref (G_OBJECT (pair->fixture->service.book_client),
+ client_weak_notify, pair->fixture);
+
break;
case E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK:
if (!e_book_open (pair->fixture->service.book, FALSE, &error))
g_error ("Unable to open book: %s", error->message);
+ g_object_weak_ref (G_OBJECT (pair->fixture->service.book),
+ client_weak_notify, pair->fixture);
+
break;
case E_TEST_SERVER_CALENDAR:
if (!pair->fixture->service.calendar_client)
g_error ("Unable to create the test calendar: %s", error->message);
+ g_object_weak_ref (G_OBJECT (pair->fixture->service.calendar_client),
+ client_weak_notify, pair->fixture);
+
break;
case E_TEST_SERVER_DEPRECATED_CALENDAR:
if (!e_cal_open (pair->fixture->service.calendar, FALSE, &error))
g_error ("Unable to open calendar: %s", error->message);
+ g_object_weak_ref (G_OBJECT (pair->fixture->service.calendar),
+ client_weak_notify, pair->fixture);
+
break;
case E_TEST_SERVER_NONE:
if (!pair->fixture->registry)
g_error ("Unable to create the test registry: %s", error->message);
+ g_object_weak_ref (G_OBJECT (pair->fixture->registry),
+ registry_weak_notify, pair->fixture);
+
g_signal_connect (
pair->fixture->registry, "source-added",
G_CALLBACK (e_test_server_utils_source_added), pair);
break;
}
+ if (closure->type != E_TEST_SERVER_NONE &&
+ fixture->client_finalized == FALSE)
+ g_error ("Failed to destroy client while tearing down test case; reference count imbalance");
+
g_free (fixture->source_name);
g_object_run_dispose (G_OBJECT (fixture->registry));
g_object_unref (fixture->registry);
fixture->registry = NULL;
+ if (fixture->registry_finalized == FALSE)
+ g_error ("Failed to destroy registry while tearing down test case; reference count imbalance");
+
g_main_loop_unref (fixture->loop);
fixture->loop = NULL;