cedric pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=bd2ae0ae85dcdb5727022d1a7cdda5f717d25a40
commit bd2ae0ae85dcdb5727022d1a7cdda5f717d25a40 Author: Cedric BAIL <cedric.b...@free.fr> Date: Fri Jan 4 14:24:28 2019 -0800 elementary: refactor selection manager to not use eina_promise_data_set. eina_promise_data_set is a misleading API and result in conflicted use by multiple independent piece of code leading to bug and crash. It is also not necessary and we can avoid using it completely. Reviewed-by: Mike Blumenkrantz <michael.blumenkra...@gmail.com> Differential Revision: https://phab.enlightenment.org/D7543 --- src/lib/elementary/efl_ui_selection_manager.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/src/lib/elementary/efl_ui_selection_manager.c b/src/lib/elementary/efl_ui_selection_manager.c index 0f1bfc71ec..20a467f759 100644 --- a/src/lib/elementary/efl_ui_selection_manager.c +++ b/src/lib/elementary/efl_ui_selection_manager.c @@ -93,8 +93,6 @@ _owner_change_check(Efl_Ui_Selection_Manager *manager, Efl_Object *owner, (sel_lost->type == type)) { eina_promise_resolve(sel_lost->promise, eina_value_uint_init(sel_lost->type)); - seat_sel2->sel_lost_list = eina_list_remove(seat_sel2->sel_lost_list, sel_lost); - free(sel_lost); } } seat_sel2->xwin = 0; @@ -138,8 +136,6 @@ _owner_change_check(Efl_Ui_Selection_Manager *manager, Efl_Object *owner, (sel_lost->type == type)) { eina_promise_resolve(sel_lost->promise, eina_value_uint_init(sel_lost->type)); - seat_sel->sel_lost_list = eina_list_remove(seat_sel->sel_lost_list, sel_lost); - free(sel_lost); } } } @@ -224,12 +220,10 @@ _sel_manager_seat_selection_init(Efl_Ui_Selection_Manager_Data *pd, unsigned int } static void -_sel_manager_promise_cancel(void *data, Efl_Loop_Consumer *consumer EINA_UNUSED, - const Eina_Promise *dead_future EINA_UNUSED) +_sel_manager_promise_cancel(Eo *obj EINA_UNUSED, void *data, const Eina_Future *dead_future EINA_UNUSED) { Sel_Manager_Selection_Lost *sel_lost = data; - sel_lost->seat_sel->sel_lost_list = eina_list_remove( - sel_lost->seat_sel->sel_lost_list, sel_lost); + sel_lost->seat_sel->sel_lost_list = eina_list_remove(sel_lost->seat_sel->sel_lost_list, sel_lost); free(sel_lost); } @@ -248,12 +242,13 @@ _update_sel_lost_list(Efl_Object *obj, Efl_Ui_Selection_Type type, sel_lost->seat_sel = seat_sel; seat_sel->sel_lost_list = eina_list_append(seat_sel->sel_lost_list, sel_lost); - p = efl_loop_promise_new(obj, NULL, _sel_manager_promise_cancel, NULL); - eina_promise_data_set(p, sel_lost); + p = efl_loop_promise_new(obj, NULL, NULL, NULL); if (!p) return NULL; sel_lost->promise = p; - return eina_future_new(p); + return efl_future_then(obj, eina_future_new(p), + .data = sel_lost, + .free = _sel_manager_promise_cancel); } /* TODO: this should not be an actual tempfile, but rather encode the object @@ -1060,8 +1055,6 @@ _x11_selection_clear(void *data, int type EINA_UNUSED, void *event) { sel_debug("resolve the promise: %p", sel_lost->promise); eina_promise_resolve(sel_lost->promise, eina_value_uint_init(sel_lost->type)); - seat_sel->sel_lost_list = eina_list_remove(seat_sel->sel_lost_list, sel_lost); - free(sel_lost); } } sel->active = EINA_FALSE; @@ -2559,8 +2552,6 @@ _wl_efl_sel_manager_selection_set(Efl_Ui_Selection_Manager_Data *pd, (sel_lost->type == type)) { eina_promise_resolve(sel_lost->promise, eina_value_uint_init(sel_lost->type)); - seat_sel->sel_lost_list = eina_list_remove(seat_sel->sel_lost_list, sel_lost); - free(sel_lost); } } } @@ -3977,8 +3968,6 @@ _cocoa_efl_sel_manager_selection_set(Efl_Ui_Selection_Manager_Data *pd, (sel_lost->type == type)) { eina_promise_resolve(sel_lost->promise, eina_value_uint_init(sel_lost->type)); - seat_sel->sel_lost_list = eina_list_remove(seat_sel->sel_lost_list, sel_lost); - free(sel_lost); } } if (sel->owner) @@ -4219,8 +4208,6 @@ _win32_efl_sel_manager_selection_set(Efl_Ui_Selection_Manager_Data *pd, (sel_lost->type == type)) { eina_promise_resolve(sel_lost->promise, eina_value_uint_init(sel_lost->type)); - seat_sel->sel_lost_list = eina_list_remove(seat_sel->sel_lost_list, sel_lost); - free(sel_lost); } } @@ -4815,8 +4802,6 @@ _efl_ui_selection_manager_selection_clear(Eo *obj, Efl_Ui_Selection_Manager_Data (sel_lost->type == type)) { eina_promise_resolve(sel_lost->promise, eina_value_uint_init(sel_lost->type)); - seat_sel->sel_lost_list = eina_list_remove(seat_sel->sel_lost_list, sel_lost); - free(sel_lost); } } seat_sel->sel_list[type].owner = NULL; --