From ebfc141d58f5dd9d6cf5f035ba3ed75ac5cd04bf Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Fri, 12 Jul 2019 18:39:07 +0200 Subject: [PATCH] efl_ui_spotlight_container: fix ownership behavior of view_manager view_manager is a property that takes ownership of the view_manager object. We are setting the parent in the setter which means, we should actaully have one ref to the parent, and one from the caller, so we need to unref one. Differential Revision: https://phab.enlightenment.org/D9304 --- src/bin/elementary/test_ui_tab_pager.c | 2 -- src/lib/elementary/efl_ui_spotlight_container.c | 7 ++++--- src/lib/elementary/efl_ui_spotlight_util.c | 2 +- src/tests/elementary/efl_ui_test_spotlight.c | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/bin/elementary/test_ui_tab_pager.c b/src/bin/elementary/test_ui_tab_pager.c index e4b1edb..512ae24 100644 --- a/src/bin/elementary/test_ui_tab_pager.c +++ b/src/bin/elementary/test_ui_tab_pager.c @@ -559,7 +559,6 @@ _tran_set_btn_scroll_cb(void *data, const Efl_Event *ev EINA_UNUSED) { Efl_Ui_Spotlight_Manager_Scroll *scroll = efl_new(EFL_UI_SPOTLIGHT_MANAGER_SCROLL_CLASS); efl_ui_spotlight_manager_set(data, scroll); - efl_unref(scroll); } static void @@ -567,7 +566,6 @@ _tran_set_btn_stack_cb(void *data, const Efl_Event *ev EINA_UNUSED) { Efl_Ui_Spotlight_Manager_Scroll *stack = efl_new(EFL_UI_SPOTLIGHT_MANAGER_STACK_CLASS); efl_ui_spotlight_manager_set(data, stack); - efl_unref(stack); } static void diff --git a/src/lib/elementary/efl_ui_spotlight_container.c b/src/lib/elementary/efl_ui_spotlight_container.c index 9906864..37ee165 100644 --- a/src/lib/elementary/efl_ui_spotlight_container.c +++ b/src/lib/elementary/efl_ui_spotlight_container.c @@ -214,9 +214,7 @@ _efl_ui_spotlight_container_efl_object_finalize(Eo *obj, Efl_Ui_Spotlight_Contai //set a view manager in case nothing is here if (!manager) { - Eo *plain; - plain = efl_add(EFL_UI_SPOTLIGHT_MANAGER_PLAIN_CLASS, obj); - efl_ui_spotlight_manager_set(obj, plain); + efl_ui_spotlight_manager_set(obj, efl_new(EFL_UI_SPOTLIGHT_MANAGER_PLAIN_CLASS)); } else { @@ -605,7 +603,10 @@ _efl_ui_spotlight_container_spotlight_manager_set(Eo *obj, Efl_Ui_Spotlight_Cont if (pd->transition) { + EINA_SAFETY_ON_FALSE_RETURN(efl_ownable_get(pd->transition)); efl_parent_set(pd->transition, obj); + //the api indicates that the caller passes ownership to this function, so we need to unref here + efl_unref(pd->transition); //disable animation when not finalized yet, this help reducing the overhead of scheduling a animation that will not be displayed efl_ui_spotlight_manager_animation_enabled_set(pd->transition, efl_finalized_get(obj)); efl_ui_spotlight_manager_bind(pd->transition, obj, diff --git a/src/lib/elementary/efl_ui_spotlight_util.c b/src/lib/elementary/efl_ui_spotlight_util.c index 308b4f3..c49ebd4 100644 --- a/src/lib/elementary/efl_ui_spotlight_util.c +++ b/src/lib/elementary/efl_ui_spotlight_util.c @@ -12,7 +12,7 @@ typedef struct { EOLIAN static Efl_Ui_Spotlight_Container* _efl_ui_spotlight_util_stack_gen(Efl_Ui_Widget *parent) { - Efl_Ui_Spotlight_Manager *manager = efl_add(EFL_UI_SPOTLIGHT_MANAGER_STACK_CLASS, parent); + Efl_Ui_Spotlight_Manager *manager = efl_new(EFL_UI_SPOTLIGHT_MANAGER_STACK_CLASS); return efl_add(EFL_UI_SPOTLIGHT_CONTAINER_CLASS, parent, efl_ui_spotlight_manager_set(efl_added, manager)); } diff --git a/src/tests/elementary/efl_ui_test_spotlight.c b/src/tests/elementary/efl_ui_test_spotlight.c index 7a39e6e..6b5a792 100644 --- a/src/tests/elementary/efl_ui_test_spotlight.c +++ b/src/tests/elementary/efl_ui_test_spotlight.c @@ -209,7 +209,7 @@ _create_transition(void) { Eo *obj; - obj = efl_add(efl_ui_spotlight_manager_realized_class_get(), win); + obj = efl_new(efl_ui_spotlight_manager_realized_class_get()); efl_object_override(obj, &transition_tracker); return obj; -- 2.7.4