From: Marcel Hollerbach Date: Tue, 25 Sep 2018 13:08:47 +0000 (+0200) Subject: efl_ui_dnd: fixup leaking inits and code duplication X-Git-Tag: submit/tizen/20181108.080505~114 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e2c8ab5d3df07205c68e814103bde976a3540200;p=platform%2Fupstream%2Fefl.git efl_ui_dnd: fixup leaking inits and code duplication In fff4d1ba97f77bbd52d9a48ce4f19b5ed55e40e4 one selection_manager_get method was patched to behave like this, however, it completly broke the fact of *only-one-manager* since the same code was duplicated in a other files (efl_selection.c). This now unifies this code, and adds back the assertion for only one manager per window. Additionally a shutdown function is added, the app never destroyes, but the selection manager decided to init some subsystems itself (ecore_x for example). This lead to to a leak of init counts in ecore_x, which lead to elementary test suite issues. This is now *finaly* fixed. Differential Revision: https://phab.enlightenment.org/D7105 Change-Id: I067367345d28030c6ff10cf3de44c97ae0375b5c --- diff --git a/src/lib/elementary/efl_selection.c b/src/lib/elementary/efl_selection.c index 84f39c8..0dc35d9 100644 --- a/src/lib/elementary/efl_selection.c +++ b/src/lib/elementary/efl_selection.c @@ -10,28 +10,11 @@ #define MY_CLASS EFL_SELECTION_MIXIN #define MY_CLASS_NAME "Efl.Selection" -static inline Eo* -_selection_manager_get(Eo *obj) -{ - Eo *top = elm_widget_top_get(obj); - if (!top) - { - top = obj; - } - Eo *sel_man = efl_key_data_get(top, "__selection_manager"); - if (!sel_man) - { - sel_man = efl_add(EFL_SELECTION_MANAGER_CLASS, top); - efl_key_data_set(top, "__selection_manager", sel_man); - } - return sel_man; -} - EOLIAN static void _efl_selection_selection_get(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, Efl_Selection_Format format, void *data_func_data, Efl_Selection_Data_Ready data_func, Eina_Free_Cb data_func_free_cb, unsigned int seat) { - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); efl_selection_manager_selection_get(sel_man, obj, type, format, data_func_data, data_func, data_func_free_cb, seat); @@ -40,21 +23,21 @@ _efl_selection_selection_get(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type t EOLIAN static Eina_Future * _efl_selection_selection_set(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, Efl_Selection_Format format, Eina_Slice data, unsigned int seat) { - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); return efl_selection_manager_selection_set(sel_man, obj, type, format, data, seat); } EOLIAN static void _efl_selection_selection_clear(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, unsigned int seat) { - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); efl_selection_manager_selection_clear(sel_man, obj, type, seat); } EOLIAN static Eina_Bool _efl_selection_has_owner(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Type type, unsigned int seat) { - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); return efl_selection_manager_selection_has_owner(sel_man, obj, type, seat); } @@ -232,13 +215,13 @@ elm_cnp_selection_get(const Evas_Object *obj, Elm_Sel_Type type, Elm_Sel_Format format, Elm_Drop_Cb datacb, void *udata) { int seatid = 1; - Eo *sel_man = _selection_manager_get((Evas_Object *)obj); + Eo *sel_man = _efl_ui_selection_manager_get((Evas_Object *)obj); Cnp_Data_Cb_Wrapper *wdata = calloc(1, sizeof(Cnp_Data_Cb_Wrapper)); if (!wdata) return EINA_FALSE; #ifdef HAVE_ELEMENTARY_WL2 - + seatid = _wl_default_seat_id_get((Evas_Object *)obj); #endif wdata->udata = udata; @@ -256,7 +239,7 @@ elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type type, int seatid = 1; Eina_Future *f; Sel_Lost_Data *ldata; - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); Eina_Slice data; ldata = calloc(1, sizeof(Sel_Lost_Data)); @@ -282,7 +265,7 @@ elm_object_cnp_selection_clear(Evas_Object *obj, Elm_Sel_Type type) if (type > ELM_SEL_TYPE_CLIPBOARD) return EINA_FALSE; int seatid = 1; - Eo *sel_man = _selection_manager_get((Evas_Object *)obj); + Eo *sel_man = _efl_ui_selection_manager_get((Evas_Object *)obj); #ifdef HAVE_ELEMENTARY_WL2 seatid = _wl_default_seat_id_get(obj); @@ -314,7 +297,7 @@ EAPI Eina_Bool elm_selection_selection_has_owner(Evas_Object *obj) { int seatid = 1; - Eo *sel_man = _selection_manager_get((Evas_Object *)obj); + Eo *sel_man = _efl_ui_selection_manager_get((Evas_Object *)obj); #ifdef HAVE_ELEMENTARY_WL2 seatid = _wl_default_seat_id_get(obj); @@ -328,7 +311,7 @@ EAPI Eina_Bool elm_cnp_clipboard_selection_has_owner(Evas_Object *obj) { int seatid = 1; - Eo *sel_man = _selection_manager_get((Evas_Object *)obj); + Eo *sel_man = _efl_ui_selection_manager_get((Evas_Object *)obj); #ifdef HAVE_ELEMENTARY_WL2 seatid = _wl_default_seat_id_get(obj); diff --git a/src/lib/elementary/efl_ui_dnd.c b/src/lib/elementary/efl_ui_dnd.c index 2f409da..36ef0ba 100644 --- a/src/lib/elementary/efl_ui_dnd.c +++ b/src/lib/elementary/efl_ui_dnd.c @@ -21,8 +21,8 @@ struct _Efl_Ui_Dnd_Container_Data extern int _wl_default_seat_id_get(Evas_Object *obj); -static inline Eo * -_selection_manager_get(Eo *obj) +Eo* +_efl_ui_selection_manager_get(Eo *obj) { if (!efl_isa(obj, EFL_UI_WIDGET_CLASS)) return NULL; Eo *app = efl_app_get(); @@ -35,12 +35,21 @@ _selection_manager_get(Eo *obj) return sel_man; } +void +_efl_ui_dnd_shutdown(void) +{ + Eo *app = efl_app_get(); + Eo *sel_man = efl_key_data_get(app, "__selection_manager"); + + efl_del(sel_man); +} + EOLIAN static void _efl_ui_dnd_drag_start(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Format format, Eina_Slice data, Efl_Selection_Action action, void *icon_func_data, Efl_Dnd_Drag_Icon_Create icon_func, Eina_Free_Cb icon_func_free_cb, unsigned int seat) { - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); efl_selection_manager_drag_start(sel_man, obj, format, data, action, icon_func_data, icon_func, icon_func_free_cb, seat); @@ -49,14 +58,14 @@ _efl_ui_dnd_drag_start(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Format forma EOLIAN static void _efl_ui_dnd_drag_cancel(Eo *obj, void *pd EINA_UNUSED, unsigned int seat) { - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); efl_selection_manager_drag_cancel(sel_man, obj, seat); } EOLIAN static void _efl_ui_dnd_drag_action_set(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Action action, unsigned int seat) { - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); efl_selection_manager_drag_action_set(sel_man, obj, action, seat); } @@ -64,14 +73,14 @@ _efl_ui_dnd_drag_action_set(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Action EOLIAN static void _efl_ui_dnd_drop_target_add(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Format format, unsigned int seat) { - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); efl_selection_manager_drop_target_add(sel_man, obj, format, seat); } EOLIAN static void _efl_ui_dnd_drop_target_del(Eo *obj, void *pd EINA_UNUSED, Efl_Selection_Format format, unsigned int seat) { - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); efl_selection_manager_drop_target_del(sel_man, obj, format, seat); } @@ -97,7 +106,7 @@ _efl_ui_dnd_container_drag_item_add(Eo *obj, Efl_Ui_Dnd_Container_Data *pd, { double drag_delay_time = pd->drag_delay_time; double anim_time = elm_config_drag_anim_duration_get(); - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); efl_selection_manager_container_drag_item_add(sel_man, obj, drag_delay_time, anim_time, data_func_data, data_func, data_func_free_cb, item_func_data, item_func, item_func_free_cb, @@ -109,7 +118,7 @@ _efl_ui_dnd_container_drag_item_add(Eo *obj, Efl_Ui_Dnd_Container_Data *pd, static void _efl_ui_dnd_container_drag_item_del(Eo *obj, Efl_Ui_Dnd_Container_Data *pd EINA_UNUSED, unsigned int seat) { - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); efl_selection_manager_container_drag_item_del(sel_man, obj, seat); } EOLIAN static void @@ -118,14 +127,14 @@ _efl_ui_dnd_container_drop_item_add(Eo *obj, Efl_Ui_Dnd_Container_Data *pd EINA_ void *item_func_data, Efl_Dnd_Item_Get item_func, Eina_Free_Cb item_func_free_cb, unsigned int seat) { - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); efl_selection_manager_container_drop_item_add(sel_man, obj, format, item_func_data, item_func, item_func_free_cb, seat); } EOLIAN static void _efl_ui_dnd_container_drop_item_del(Eo *obj, Efl_Ui_Dnd_Container_Data *pd EINA_UNUSED, unsigned int seat) { - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); efl_selection_manager_container_drop_item_del(sel_man, obj, seat); } @@ -306,8 +315,8 @@ elm_drag_start(Evas_Object *obj, Elm_Sel_Format format, const char *data, Elm_Drag_State drag_done_cb, void *drag_done_data) { if (!obj) return EINA_FALSE; - - Eo *sel_man = _selection_manager_get(obj); + if (!data) return EINA_FALSE; + Eo *sel_man = _efl_ui_selection_manager_get(obj); int seatid = 1; Eina_Slice sl; sl.mem = NULL; @@ -364,7 +373,7 @@ EAPI Eina_Bool elm_drag_action_set(Evas_Object *obj, Elm_Xdnd_Action action) { if (!obj) return EINA_FALSE; - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); int seatid = 1; #ifdef HAVE_ELEMENTARY_WL2 @@ -378,7 +387,7 @@ elm_drag_action_set(Evas_Object *obj, Elm_Xdnd_Action action) EAPI Eina_Bool elm_drag_cancel(Evas_Object *obj) { - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); int seatid = 1; #ifdef HAVE_ELEMENTARY_WL2 @@ -423,7 +432,7 @@ elm_drop_target_add(Evas_Object *obj, Elm_Sel_Format format, Elm_Drop_Cb drop_cb, void *drop_data) { if (!obj) return EINA_FALSE; - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); int seatid = 1; Dnd_Drag_State *enter = NULL, *leave = NULL; Dnd_Drag_Pos *pos = NULL; @@ -486,7 +495,7 @@ elm_drop_target_del(Evas_Object *obj, Elm_Sel_Format format, Elm_Drop_Cb drop_cb, void *drop_data) { if(!obj) return EINA_FALSE; - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); int seatid = 1; //Eina_List *l, *l2; Eina_List *drop_list; @@ -641,7 +650,7 @@ elm_drop_item_container_add(Evas_Object *obj, Elm_Drag_Item_Container_Pos pos_cb, void *pos_data, Elm_Drop_Item_Container_Cb drop_cb, void *drop_data) { - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); int seatid = 1; Dnd_Drag_State *enter = NULL, *leave = NULL; Dnd_Cont_Drag_Pos *pos = NULL; @@ -704,7 +713,7 @@ EAPI Eina_Bool elm_drop_item_container_del(Evas_Object *obj) { if (!obj) return EINA_FALSE; - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); int seatid = 1; #ifdef HAVE_ELEMENTARY_WL2 @@ -803,7 +812,7 @@ EAPI Eina_Bool elm_drag_item_container_add(Evas_Object *obj, double anim_tm, double tm_to_drag, Elm_Xy_Item_Get_Cb item_get_cb, Elm_Item_Container_Data_Get_Cb data_get_cb) { - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); int seatid = 1; Eina_List *di_list; Item_Container_Drag_Info *di; @@ -832,7 +841,7 @@ elm_drag_item_container_add(Evas_Object *obj, double anim_tm, double tm_to_drag, EAPI Eina_Bool elm_drag_item_container_del(Evas_Object *obj) { - Eo *sel_man = _selection_manager_get(obj); + Eo *sel_man = _efl_ui_selection_manager_get(obj); int seatid = 1; #ifdef HAVE_ELEMENTARY_WL2 diff --git a/src/lib/elementary/elm_main.c b/src/lib/elementary/elm_main.c index c929b34..d1aa36e 100644 --- a/src/lib/elementary/elm_main.c +++ b/src/lib/elementary/elm_main.c @@ -901,6 +901,7 @@ elm_quicklaunch_sub_shutdown(void) _elm_module_shutdown(); if (_elm_prefs_initted) _elm_prefs_shutdown(); + _efl_ui_dnd_shutdown(); elm_color_class_shutdown(); } diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h index cd86e09..31d72ce 100644 --- a/src/lib/elementary/elm_priv.h +++ b/src/lib/elementary/elm_priv.h @@ -563,6 +563,10 @@ void _elm_prefs_shutdown(void); void _elm_prefs_data_init(void); void _elm_prefs_data_shutdown(void); +/* init functions for dnd and cnp */ +Eo* _efl_ui_selection_manager_get(Eo *obj); +void _efl_ui_dnd_shutdown(void); + int _elm_ews_wm_init(void); void _elm_ews_wm_shutdown(void); void _elm_ews_wm_rescale(Elm_Theme *th,