From: Seunghun Lee Date: Wed, 13 May 2020 09:09:59 +0000 (+0900) Subject: subsurface: create 'wl_resource' for wl_subsurface at one place. X-Git-Tag: submit/tizen/20200825.082113~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f1f84e8335b1bae99d14ed56c68bd223f88c6b62;p=platform%2Fupstream%2Fenlightenment.git subsurface: create 'wl_resource' for wl_subsurface at one place. Change-Id: I1aeab454ee00e09f14abaf4232b2598fe1099245 --- diff --git a/src/bin/e_comp_wl_subsurface.c b/src/bin/e_comp_wl_subsurface.c index a71e73f34d..d5329235c2 100644 --- a/src/bin/e_comp_wl_subsurface.c +++ b/src/bin/e_comp_wl_subsurface.c @@ -6,7 +6,7 @@ static struct wl_global *global = NULL; static Eina_List *hooks = NULL; static Eina_Bool _e_comp_wl_subsurface_circular_reference_check(E_Client *ec, E_Client *parent); -static void _e_comp_wl_subsurface_invalid_parent_handle(E_Client *ec, struct wl_client *client, uint32_t id); +static void _e_comp_wl_subsurface_invalid_parent_handle(E_Client *ec, struct wl_resource *resource); static void _e_comp_wl_subsurface_restack_bg_rectangle(E_Client *ec) @@ -880,10 +880,18 @@ e_comp_wl_subsurface_create(E_Client *ec, E_Client *epc, uint32_t id, struct wl_ if (e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) return EINA_FALSE; + res = wl_resource_create(client, &wl_subsurface_interface, 1, id); + if (!res) + { + ERR("Failed to create subsurface resource"); + wl_resource_post_no_memory(surface_resource); + return EINA_FALSE; + } + if (!epc || e_object_is_del(E_OBJECT(epc))) { ERR("tizen_policy failed: invalid parent"); - _e_comp_wl_subsurface_invalid_parent_handle(ec, client, id); + _e_comp_wl_subsurface_invalid_parent_handle(ec, res); return EINA_FALSE; } @@ -900,6 +908,7 @@ e_comp_wl_subsurface_create(E_Client *ec, E_Client *epc, uint32_t id, struct wl_ ERR("Subsurface parent relationship is a cycle : [child win : %zx, %s], [parent win : %zx, %s]", e_client_util_win_get(ec), e_client_util_name_get(ec), e_client_util_win_get(epc), e_client_util_name_get(epc)); + wl_resource_destroy(res); return EINA_FALSE; } @@ -907,15 +916,8 @@ e_comp_wl_subsurface_create(E_Client *ec, E_Client *epc, uint32_t id, struct wl_ if (!(sdata = E_NEW(E_Comp_Wl_Subsurf_Data, 1))) { ERR("Could not allocate space for subsurface data"); - goto dat_err; - } - - /* try to create the subsurface resource */ - if (!(res = wl_resource_create(client, &wl_subsurface_interface, 1, id))) - { - ERR("Failed to create subsurface resource"); - wl_resource_post_no_memory(surface_resource); - goto res_err; + wl_resource_destroy(res); + return EINA_FALSE; } /* set resource implementation */ @@ -988,12 +990,8 @@ e_comp_wl_subsurface_create(E_Client *ec, E_Client *epc, uint32_t id, struct wl_ E_FREE_FUNC(ec->comp_data->sub.below_obj, evas_object_del); e_comp_wl_hook_call(E_COMP_WL_HOOK_SUBSURFACE_CREATE, ec); - return EINA_TRUE; -res_err: - free(sdata); -dat_err: - return EINA_FALSE; + return EINA_TRUE; } EINTERN void @@ -1239,10 +1237,8 @@ static const struct wl_subsurface_interface _e_subsurface_dummy_interface = }; static void -_e_comp_wl_subsurface_invalid_parent_handle(E_Client *ec, struct wl_client *client, uint32_t id) +_e_comp_wl_subsurface_invalid_parent_handle(E_Client *ec, struct wl_resource *resource) { - struct wl_resource *res; - if (ec->comp_data->sub.watcher) tizen_subsurface_watcher_send_message(ec->comp_data->sub.watcher, TIZEN_SUBSURFACE_WATCHER_MSG_PARENT_ID_INVALID); @@ -1250,12 +1246,5 @@ _e_comp_wl_subsurface_invalid_parent_handle(E_Client *ec, struct wl_client *clie * because server will send the fatal error when a client destroy a subsurface object. * Otherwise, server will kill a client by the fatal error. */ - if (!(res = wl_resource_create(client, &wl_subsurface_interface, 1, id))) - { - ERR("Failed to create subsurface resource"); - wl_client_post_no_memory(client); - return; - } - - wl_resource_set_implementation(res, &_e_subsurface_dummy_interface, NULL, NULL); + wl_resource_set_implementation(resource, &_e_subsurface_dummy_interface, NULL, NULL); }