From acd0e4b03622dcdee72833e68b1a3d7cb06c3683 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Fri, 23 Jun 2017 10:24:44 -0500 Subject: [PATCH] Refactor wayland buffer releasing This code should've been common but wasn't, so this might fix some resource leaks. --- src/bin/e_pixmap.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/bin/e_pixmap.c b/src/bin/e_pixmap.c index 0ddd646b9..6b0f4d9ee 100644 --- a/src/bin/e_pixmap.c +++ b/src/bin/e_pixmap.c @@ -132,6 +132,21 @@ _e_pixmap_image_clear_x(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U #endif #ifdef HAVE_WAYLAND +static void +_e_pixmap_wl_resource_release(E_Comp_Wl_Buffer *buffer) +{ + buffer->busy--; + if (buffer->busy) return; + + if (buffer->pool) + { + wl_shm_pool_unref(buffer->pool); + buffer->pool = NULL; + } + + wl_resource_queue_event(buffer->resource, WL_BUFFER_RELEASE); +} + static void _e_pixmap_wayland_buffer_release(E_Pixmap *cp, E_Comp_Wl_Buffer *buffer) { @@ -148,12 +163,7 @@ _e_pixmap_wayland_buffer_release(E_Pixmap *cp, E_Comp_Wl_Buffer *buffer) return; } - buffer->busy--; - if (buffer->busy) return; - - wl_resource_queue_event(buffer->resource, WL_BUFFER_RELEASE); - wl_shm_pool_unref(buffer->pool); - buffer->pool = NULL; + _e_pixmap_wl_resource_release(buffer); } static void @@ -649,10 +659,8 @@ e_pixmap_resource_set(E_Pixmap *cp, void *resource) if (cp->buffer == resource) return; if (cp->buffer) - { - cp->buffer->busy--; - if (!cp->buffer->busy) wl_resource_queue_event(cp->buffer->resource, WL_BUFFER_RELEASE); - } + _e_pixmap_wl_resource_release(cp->buffer); + if (cp->buffer_destroy_listener.notify) { wl_list_remove(&cp->buffer_destroy_listener.link);