From a2c8a8c6309d223d44ac512c7646fbcd271bb8d0 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 14 Dec 2022 09:33:18 +0000 Subject: [PATCH] tests: Release GApplication a little later to avoid assertion failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If it takes one more `GMainContext` cycle than expected for the `activate` signals to be handled, the `GApplication` under test can be released too early, and the test will fail due to not seeing a high enough value of `n_activations`. Hopefully avoid that by moving the release to a low priority idle callback. This fix is only hopeful because I’ve only been able to reproduce the failure on FreeBSD CI and not locally. Signed-off-by: Philip Withnall Fixes: #2835 --- gio/tests/gapplication.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gio/tests/gapplication.c b/gio/tests/gapplication.c index a1eb85be7..4320352d1 100644 --- a/gio/tests/gapplication.c +++ b/gio/tests/gapplication.c @@ -1207,6 +1207,7 @@ dbus_activate_cb (GApplication *app, static void dbus_startup_reply_cb (GObject *source_object, GAsyncResult *result, gpointer user_data); +static gboolean dbus_startup_reply_idle_cb (gpointer user_data); static void dbus_startup_cb (GApplication *app, @@ -1241,8 +1242,19 @@ dbus_startup_reply_cb (GObject *source_object, /* Nothing to check on the reply for now. */ g_clear_object (&reply); + /* Release the app in an idle callback, so there’s time to process other + * pending sources first. */ + g_idle_add_full (G_PRIORITY_LOW, dbus_startup_reply_idle_cb, g_steal_pointer (&app), g_object_unref); +} + +static gboolean +dbus_startup_reply_idle_cb (gpointer user_data) +{ + GApplication *app = G_APPLICATION (user_data); + g_application_release (app); - g_clear_object (&app); + + return G_SOURCE_REMOVE; } static void