tbm_server: Reference/unreference tbm_surface 39/301139/1
authorSeunghun Lee <shiin.lee@samsung.com>
Mon, 6 Nov 2023 00:49:15 +0000 (09:49 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Thu, 9 Nov 2023 10:02:41 +0000 (19:02 +0900)
This is to prevent tbm_surface from being destroyed while ds_buffer is
alive.

Change-Id: Iaab843d721d01b82a774094d91f03629e0a98fa4

src/tbm_server/tbm_server.c
src/tbm_server/tbm_server.h

index 693f8a9..0001d9f 100644 (file)
@@ -110,7 +110,10 @@ tbm_client_buffer_handle_resource_destroy(struct wl_listener *listener,
     buffer = wl_container_of(listener, buffer, resource_destroy);
 
     buffer->resource = NULL;
+
+    tbm_surface_internal_unref(buffer->surface);
     buffer->surface = NULL;
+
     wl_list_remove(&buffer->resource_destroy.link);
     wl_list_init(&buffer->resource_destroy.link);
 
@@ -220,6 +223,7 @@ tbm_client_buffer_create(struct wl_resource *resource)
     ds_buffer_init(&buffer->base, &tbm_client_buffer_iface, width, height);
 
     buffer->resource = resource;
+    tbm_surface_internal_ref(surface);
     buffer->surface = surface;
     buffer->format = tbm_surface_get_format(surface);
 
index 3ae00f3..c045496 100644 (file)
@@ -4,6 +4,7 @@
 #include <wayland-server.h>
 #include <wayland-tbm-server.h>
 #include <tbm_surface.h>
+#include <tbm_surface_internal.h>
 #include <libds/interfaces/buffer.h>
 #include <libds-tizen/types/tbm_server.h>