From 86edb5721a331f314fad9e81492f119f30260f0e Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Wed, 20 Apr 2022 20:11:59 +0900 Subject: [PATCH] examples/tinyds: Clean up all views when finish server Even though all view would have been cleaned up by an destroy event of xdg_surface, this is just to clean up views explicitly just in case. No functional changes. Change-Id: If92f6ee73d1b8a4043f93105478b8fc3e7e78c68 --- src/examples/tinyds.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/examples/tinyds.c b/src/examples/tinyds.c index 0c88849..64aac83 100644 --- a/src/examples/tinyds.c +++ b/src/examples/tinyds.c @@ -109,6 +109,7 @@ static void output_handle_frame(struct wl_listener *listener, void *data); static void draw_server(struct tinyds_server *server); static void draw_server_with_damage(struct tinyds_server *server); static void draw_output(struct tinyds_output *output); +static void view_destroy(struct tinyds_view *view); static void draw_view(struct tinyds_view *view, pixman_image_t *dst_image); int @@ -195,12 +196,7 @@ view_handle_xdg_surface_destroy(struct wl_listener *listener, draw_server_with_damage(view->server); - wl_list_remove(&view->xdg_surface_destroy.link); - wl_list_remove(&view->xdg_surface_map.link); - wl_list_remove(&view->xdg_surface_unmap.link); - wl_list_remove(&view->surface_commit.link); - wl_list_remove(&view->link); - free(view); + view_destroy(view); } static void @@ -288,6 +284,11 @@ init_server(struct tinyds_server *server, struct wl_display *display) static void fini_server(struct tinyds_server *server) { + struct tinyds_view *view, *tmp; + + wl_list_for_each_safe(view, tmp, &server->views, link) + view_destroy(view); + wl_list_remove(&server->new_xdg_surface.link); } @@ -419,6 +420,19 @@ out: } static void +view_destroy(struct tinyds_view *view) +{ + ds_inf("View(%p) destroyed", view); + + wl_list_remove(&view->xdg_surface_destroy.link); + wl_list_remove(&view->xdg_surface_map.link); + wl_list_remove(&view->xdg_surface_unmap.link); + wl_list_remove(&view->surface_commit.link); + wl_list_remove(&view->link); + free(view); +} + +static void draw_view(struct tinyds_view *view, pixman_image_t *dst_image) { struct ds_buffer *buffer; -- 2.7.4