From b576969a85b1635f1a2185f193a90ddb1aab4318 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Mon, 17 Jan 2022 13:48:50 +0900 Subject: [PATCH] e_comp_wl: fix resource leak related with subsurface's below object There was resource leaks related with below object of a subsurface. - ec->comp_data->sub.below_obj_map_transform_hook - ec->comp_data->sub.below_obj_map When the ec was destroyed, above resources was not freed. This patch resolve this problem. Change-Id: I582c91749d7d5daf2df34d582546cb939348696d --- src/bin/e_comp_wl.h | 1 + src/bin/e_comp_wl_subsurface.c | 35 +++++++++++++++-------------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/bin/e_comp_wl.h b/src/bin/e_comp_wl.h index 45b93be..27676a4 100644 --- a/src/bin/e_comp_wl.h +++ b/src/bin/e_comp_wl.h @@ -397,6 +397,7 @@ struct _E_Comp_Wl_Client_Data Evas_Object *below_obj; E_Map *below_obj_map; E_Client_Hook *below_obj_map_transform_hook; + E_Comp_Wl_Hook *comp_wl_del_hook; Eina_Bool restacking : 1; diff --git a/src/bin/e_comp_wl_subsurface.c b/src/bin/e_comp_wl_subsurface.c index ab84592..b92f87a 100644 --- a/src/bin/e_comp_wl_subsurface.c +++ b/src/bin/e_comp_wl_subsurface.c @@ -38,6 +38,7 @@ static void _e_comp_wl_subsurface_child_remove(E_Comp_Wl_Client_Data *pare static void _e_comp_wl_subsurface_place_above(E_Client *parent, E_Client *subc, E_Client *above); static void _e_comp_wl_subsurface_place_below(E_Client *parent, E_Client *subc, E_Client *below); static void _e_comp_wl_subsurface_stack_update(E_Client *ec); +static void _e_comp_wl_subsurface_below_obj_destroy(E_Client *ec); static E_Subsurface *_e_comp_wl_subsurface_create(struct wl_resource *resource, E_Client *ec, E_Client *epc, E_Client *offscreen_parent); static void _e_comp_wl_subsurface_destroy(E_Subsurface *sub); @@ -172,28 +173,18 @@ _e_comp_wl_subsurface_bg_cb_hook_transform_change(void *data, E_Client *ec) } static void -_e_comp_wl_subsurface_bg_evas_cb_del(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event EINA_UNUSED) +_e_comp_wl_subsurface_bg_cb_hook_del(void *data, E_Client *ec) { - Evas_Object *below_obj; - E_Client *ec; - - below_obj = data; - evas_object_del(below_obj); + if (!ec) return; - ec = e_comp_object_client_get(obj); - if ((ec) && (ec->comp_data)) + if (ec->comp_data) { - ec->comp_data->sub.below_obj = NULL; - if (ec->comp_data->sub.below_obj_map) + if (ec->comp_data->sub.below_obj) { - e_map_free(ec->comp_data->sub.below_obj_map); - ec->comp_data->sub.below_obj_map = NULL; + ELOGF("COMP", "below_obj becomes useless by destroyed ec. argb(%d)", ec, ec->argb); + _e_comp_wl_subsurface_below_obj_destroy(ec); } - E_FREE_FUNC(ec->comp_data->sub.below_obj_map_transform_hook, e_client_hook_del); } - - evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL, - _e_comp_wl_subsurface_bg_evas_cb_del); } static Eina_Bool @@ -270,6 +261,10 @@ _e_comp_wl_subsurface_below_obj_create(E_Client *ec) e_client_hook_add(E_CLIENT_HOOK_TRANSFORM_CHANGE, _e_comp_wl_subsurface_bg_cb_hook_transform_change, ec); + ec->comp_data->sub.comp_wl_del_hook = + e_comp_wl_hook_add(E_COMP_WL_HOOK_DEL, + _e_comp_wl_subsurface_bg_cb_hook_del, + ec); e_comp_wl_subsurface_bg_rectangle_map_apply(ec); @@ -280,8 +275,6 @@ _e_comp_wl_subsurface_below_obj_create(E_Client *ec) evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_RESIZE, _e_comp_wl_subsurface_bg_evas_cb_resize, ec); - evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_DEL, - _e_comp_wl_subsurface_bg_evas_cb_del, below_obj); /* set alpha only if SW path */ e_comp_object_alpha_set(ec->frame, EINA_TRUE); @@ -306,9 +299,10 @@ _e_comp_wl_subsurface_below_obj_create(E_Client *ec) static void _e_comp_wl_subsurface_below_obj_destroy(E_Client *ec) { + if (!ec->comp_data) return; + ELOGF("COMP", " |bg_rectangle(%p) delete", ec, ec->comp_data->sub.below_obj); - evas_object_event_callback_del(ec->frame, EVAS_CALLBACK_DEL, - _e_comp_wl_subsurface_bg_evas_cb_del); + E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del); if (ec->comp_data->sub.below_obj_map) @@ -317,6 +311,7 @@ _e_comp_wl_subsurface_below_obj_destroy(E_Client *ec) ec->comp_data->sub.below_obj_map = NULL; } E_FREE_FUNC(ec->comp_data->sub.below_obj_map_transform_hook, e_client_hook_del); + E_FREE_FUNC(ec->comp_data->sub.comp_wl_del_hook, e_comp_wl_hook_del); } static void -- 2.7.4