From adf9d8b0bec7a9e25e1f124f1bcf326102f5b406 Mon Sep 17 00:00:00 2001 From: Consolatis <40171-Consolatis@users.noreply.gitlab.freedesktop.org> Date: Mon, 12 Aug 2024 22:06:01 +0200 Subject: [PATCH] ext-foreign-toplevel-list: use correct interface and add missing handler Without this patch, a client calling handle.destroy() will trigger an assert in libwayland due to a NULL pointer for the destroy handler. Also implement a missing .destroy handler for the manager itself and delay destruction of the manager resource from the .stop handler to the .destroy handler. --- types/wlr_ext_foreign_toplevel_list_v1.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/types/wlr_ext_foreign_toplevel_list_v1.c b/types/wlr_ext_foreign_toplevel_list_v1.c index 6c059e64..22a126f8 100644 --- a/types/wlr_ext_foreign_toplevel_list_v1.c +++ b/types/wlr_ext_foreign_toplevel_list_v1.c @@ -12,14 +12,18 @@ #define FOREIGN_TOPLEVEL_LIST_V1_VERSION 1 -static const struct ext_foreign_toplevel_list_v1_interface toplevel_handle_impl; +static const struct ext_foreign_toplevel_handle_v1_interface toplevel_handle_impl; static void foreign_toplevel_handle_destroy(struct wl_client *client, struct wl_resource *resource) { + assert(wl_resource_instance_of(resource, + &ext_foreign_toplevel_handle_v1_interface, + &toplevel_handle_impl)); + wl_resource_destroy(resource); } -static const struct ext_foreign_toplevel_list_v1_interface toplevel_handle_impl = { +static const struct ext_foreign_toplevel_handle_v1_interface toplevel_handle_impl = { .destroy = foreign_toplevel_handle_destroy, }; @@ -191,12 +195,23 @@ static void foreign_toplevel_list_handle_stop(struct wl_client *client, &foreign_toplevel_list_impl)); ext_foreign_toplevel_list_v1_send_finished(resource); + wl_list_remove(wl_resource_get_link(resource)); + wl_list_init(wl_resource_get_link(resource)); +} + +static void foreign_toplevel_list_handle_destroy(struct wl_client *client, + struct wl_resource *resource) { + assert(wl_resource_instance_of(resource, + &ext_foreign_toplevel_list_v1_interface, + &foreign_toplevel_list_impl)); + wl_resource_destroy(resource); } static const struct ext_foreign_toplevel_list_v1_interface foreign_toplevel_list_impl = { - .stop = foreign_toplevel_list_handle_stop + .stop = foreign_toplevel_list_handle_stop, + .destroy = foreign_toplevel_list_handle_destroy }; static void foreign_toplevel_list_resource_destroy(