diff --git a/gio/tests/gapplication.c b/gio/tests/gapplication.c index 9646874b9..1a2600099 100644 --- a/gio/tests/gapplication.c +++ b/gio/tests/gapplication.c @@ -1071,6 +1071,8 @@ typedef struct { gboolean allow_replacement; GSubprocess *subprocess; + GApplication *app; /* (not owned) */ + guint timeout_id; } TestReplaceData; static void @@ -1116,11 +1118,12 @@ activate (gpointer data) } static gboolean -quit_already (gpointer data) +quit_already (gpointer user_data) { - GApplication *app = data; + TestReplaceData *data = user_data; - g_application_quit (app); + g_application_quit (data->app); + data->timeout_id = 0; return G_SOURCE_REMOVE; } @@ -1159,22 +1162,22 @@ test_replace (gconstpointer data) gboolean name_lost = FALSE; TestReplaceData data; GTestDBus *bus; - guint timeout_id = 0; data.allow_replacement = allow; data.subprocess = NULL; + data.timeout_id = 0; bus = g_test_dbus_new (0); g_test_dbus_up (bus); - app = g_application_new ("org.gtk.TestApplication.Replace", allow ? G_APPLICATION_ALLOW_REPLACEMENT : G_APPLICATION_DEFAULT_FLAGS); + app = data.app = g_application_new ("org.gtk.TestApplication.Replace", allow ? G_APPLICATION_ALLOW_REPLACEMENT : G_APPLICATION_DEFAULT_FLAGS); g_application_set_inactivity_timeout (app, 500); g_signal_connect (app, "name-lost", G_CALLBACK (name_was_lost), &name_lost); g_signal_connect (app, "startup", G_CALLBACK (startup_cb), &data); g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); if (!allow) - timeout_id = g_timeout_add_seconds (1, quit_already, app); + data.timeout_id = g_timeout_add_seconds (1, quit_already, &data); g_application_run (app, G_N_ELEMENTS (argv) - 1, argv); @@ -1184,7 +1187,7 @@ test_replace (gconstpointer data) else g_assert_false (name_lost); - g_clear_handle_id (&timeout_id, g_source_remove); + g_clear_handle_id (&data.timeout_id, g_source_remove); g_object_unref (app); g_free (binpath);