backend-wayland: immediately unref the renderbuffer for use shm buffers

wayland_output_destroy_shm_buffers() is called immediately before
output_destroy() of the renderer is called. And for the pixman renderer all
renderbuffers must be destroyed before the output can be destroyed.
Also, weston_renderbuffer_unref() is not called when the buffer is released
because buffer->output is now NULL, so the renderbuffer would be leaked.

So just unref the renderbuffer immediately. Set it to NULL to avoid unreffing it
again should wayland_output_destroy_shm_buffers() be called again before the
buffer is released. This can happen during an xdg-shell resize.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
This commit is contained in:
Michael Olbrich 2023-02-16 17:59:13 +01:00 committed by Daniel Stone
parent 455f24be9c
commit 6b23ffabcf

View File

@ -671,8 +671,13 @@ wayland_output_destroy_shm_buffers(struct wayland_output *output)
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)
wl_list_for_each(buffer, &output->shm.buffers, link) {
if (buffer->renderbuffer) {
weston_renderbuffer_unref(buffer->renderbuffer);
buffer->renderbuffer = NULL;
}
buffer->output = NULL;
}
}
static int