From 2e6625258295587912a030eb4b2f225f46fdf76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20Krezovi=C4=87?= Date: Sun, 9 Oct 2016 17:30:29 +0200 Subject: [PATCH] compositor-wayland: Destroy shm buffers on output disable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Armin Krezović --- libweston/compositor-wayland.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c index ec5df907..775da252 100644 --- a/libweston/compositor-wayland.c +++ b/libweston/compositor-wayland.c @@ -629,6 +629,19 @@ wayland_backend_destroy_output_surface(struct wayland_output *output) wl_surface_destroy(output->parent.surface); } +static void +wayland_output_destroy_shm_buffers(struct wayland_output *output) +{ + struct wayland_shm_buffer *buffer, *next; + + /* Throw away any remaining SHM buffers */ + wl_list_for_each_safe(buffer, next, &output->shm.free_buffers, free_link) + wayland_shm_buffer_destroy(buffer); + /* These will get thrown away when they get released */ + wl_list_for_each(buffer, &output->shm.buffers, link) + buffer->output = NULL; +} + static int wayland_output_disable(struct weston_output *base) { @@ -645,6 +658,8 @@ wayland_output_disable(struct weston_output *base) wl_egl_window_destroy(output->gl.egl_window); } + wayland_output_destroy_shm_buffers(output); + wayland_backend_destroy_output_surface(output); if (output->frame) @@ -719,7 +734,6 @@ wayland_output_resize_surface(struct wayland_output *output) { struct wayland_backend *b = to_wayland_backend(output->base.compositor); - struct wayland_shm_buffer *buffer, *next; int32_t ix, iy, iwidth, iheight; int32_t width, height; struct wl_region *region; @@ -783,12 +797,7 @@ wayland_output_resize_surface(struct wayland_output *output) output->gl.border.bottom = NULL; } - /* Throw away any remaining SHM buffers */ - wl_list_for_each_safe(buffer, next, &output->shm.free_buffers, free_link) - wayland_shm_buffer_destroy(buffer); - /* These will get thrown away when they get released */ - wl_list_for_each(buffer, &output->shm.buffers, link) - buffer->output = NULL; + wayland_output_destroy_shm_buffers(output); } static int