diff --git a/src/tests/meta-wayland-test-driver.c b/src/tests/meta-wayland-test-driver.c index 40dcc70d2..d418fa14f 100644 --- a/src/tests/meta-wayland-test-driver.c +++ b/src/tests/meta-wayland-test-driver.c @@ -214,7 +214,11 @@ static const struct test_driver_interface meta_test_driver_interface = { static void test_driver_destructor (struct wl_resource *resource) { - MetaWaylandTestDriver *test_driver = wl_resource_get_user_data (resource); + MetaWaylandTestDriver *test_driver; + + test_driver = wl_resource_get_user_data (resource); + if (!test_driver) + return; test_driver->resources = g_list_remove (test_driver->resources, resource); } @@ -246,6 +250,15 @@ static void meta_wayland_test_driver_finalize (GObject *object) { MetaWaylandTestDriver *test_driver = META_WAYLAND_TEST_DRIVER (object); + GList *l; + + for (l = test_driver->resources; l; l = l->next) + { + struct wl_resource *resource = l->data; + + wl_resource_set_user_data (resource, NULL); + } + g_clear_list (&test_driver->resources, NULL); g_clear_pointer (&test_driver->test_driver, wl_global_destroy); g_clear_pointer (&test_driver->properties, g_hash_table_unref);