From e15b4b8fbeef24f6dcb854e23a976f92dd3346bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 26 May 2021 19:31:02 +0200 Subject: [PATCH] test-runner: Disconnect display-opened signal on destruction When running multiple tests at once (with --all) as in the installed-tests cases, we may open and close the display multiple times, this leads to setting the alarm filter each time that the x11 display is opened (causing a critical error) because we never disconnect from the ::x11-display-opened signal. So disconnect from the signal on test destruction, to avoid this to be emitted multiple times. Part-of: --- src/tests/test-runner.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c index eb15a0752..9d0c69880 100644 --- a/src/tests/test-runner.c +++ b/src/tests/test-runner.c @@ -40,6 +40,7 @@ typedef struct { AsyncWaiter *waiter; GString *warning_messages; GMainLoop *loop; + gulong x11_display_opened_handler_id; } TestCase; static gboolean @@ -87,9 +88,10 @@ test_case_new (void) if (display->x11_display) on_x11_display_opened (display, test); else - g_signal_connect (meta_get_display (), "x11-display-opened", - G_CALLBACK (on_x11_display_opened), - test); + test->x11_display_opened_handler_id = + g_signal_connect (meta_get_display (), "x11-display-opened", + G_CALLBACK (on_x11_display_opened), + test); } test->clients = g_hash_table_new (g_str_hash, g_str_equal); @@ -885,6 +887,7 @@ test_case_destroy (TestCase *test, */ GHashTableIter iter; gpointer key, value; + MetaDisplay *display; g_hash_table_iter_init (&iter, test->clients); while (g_hash_table_iter_next (&iter, &key, &value)) @@ -906,11 +909,10 @@ test_case_destroy (TestCase *test, g_clear_pointer (&test->waiter, async_waiter_destroy); - if (meta_get_display ()->x11_display) - { - meta_x11_display_set_alarm_filter (meta_get_display ()->x11_display, - NULL, NULL); - } + display = meta_get_display (); + g_clear_signal_handler (&test->x11_display_opened_handler_id, display); + if (display->x11_display) + meta_x11_display_set_alarm_filter (display->x11_display, NULL, NULL); g_hash_table_destroy (test->clients); g_free (test);