From 404093c7010f44941a2b383dcdbe7770b28a8807 Mon Sep 17 00:00:00 2001 From: Jaehyun Cho Date: Wed, 22 Jan 2014 22:13:51 +0900 Subject: [PATCH] [naviframe] Fix to enable item deletion in pop_cb Summary: Fix to enable item deletion in the registered pop_cb function Reviewers: Hermet Reviewed By: Hermet CC: seoz Differential Revision: https://phab.enlightenment.org/D487 --- legacy/elementary/src/lib/elc_naviframe.c | 15 +++++++++++++++ legacy/elementary/src/lib/elm_widget_naviframe.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/legacy/elementary/src/lib/elc_naviframe.c b/legacy/elementary/src/lib/elc_naviframe.c index a2a1f85..c89fd0a 100644 --- a/legacy/elementary/src/lib/elc_naviframe.c +++ b/legacy/elementary/src/lib/elc_naviframe.c @@ -504,6 +504,9 @@ _item_del_pre_hook(Elm_Object_Item *it) nit = (Elm_Naviframe_Item *)it; ELM_NAVIFRAME_DATA_GET(WIDGET(nit), sd); + nit->delete_me = EINA_TRUE; + if (nit->ref > 0) return EINA_FALSE; + ecore_animator_del(nit->animator); top = (it == elm_naviframe_top_item_get(WIDGET(nit))); @@ -1696,14 +1699,26 @@ _item_pop(Eo *obj, void *_pd, va_list *list) if (it->popping) return; it->popping = EINA_TRUE; + evas_object_ref(obj); if (it->pop_cb) { + it->ref++; if (!it->pop_cb(it->pop_data, (Elm_Object_Item *)it)) { + it->ref--; + if (it->delete_me) + { + _item_del_pre_hook(it); + _elm_widget_item_free(it); + } it->popping = EINA_FALSE; + evas_object_unref(obj); + return; } + it->ref--; } + evas_object_unref(obj); if (sd->preserve) content = it->content; diff --git a/legacy/elementary/src/lib/elm_widget_naviframe.h b/legacy/elementary/src/lib/elm_widget_naviframe.h index 83809f9..1b4d3fc 100644 --- a/legacy/elementary/src/lib/elm_widget_naviframe.h +++ b/legacy/elementary/src/lib/elm_widget_naviframe.h @@ -57,6 +57,8 @@ struct _Elm_Naviframe_Item Eina_Bool title_enabled : 1; Eina_Bool unfocusable : 1; Eina_Bool popping : 1; + Eina_Bool delete_me : 1; + int ref; }; typedef struct _Elm_Naviframe_Content_Item_Pair Elm_Naviframe_Content_Item_Pair; -- 2.7.4