From 62cf70034de38b17f2025e08f81b5758b3d6d6e3 Mon Sep 17 00:00:00 2001 From: Jaehwan Kim Date: Mon, 30 May 2016 09:47:39 +0900 Subject: [PATCH] widget: set the parent-child relation again, when the widget is unset Summary: When the widget is unset from any container, a parent of the widget doesn't exist. So we should set its parent to the top object. But if we just set sd->parent, the parent can not find the widget as a child. So the container widgets set the parent-child relation when sub object is unset. This commit is related to 0822ad2195d335d65208856e6e590ac47691d920. @fix Test Plan: Check this issue. https://phab.enlightenment.org/D3855 The unset widget don't added any widget as child. So when it set scale, the widget can not reload the thmeme. Reviewers: raster, cedric, Hermet, reutskiy.v.v Reviewed By: Hermet, reutskiy.v.v Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D3957 Conflicts: src/lib/elementary/elm_mapbuf.c --- src/lib/elementary/efl_ui_box.c | 4 ++-- src/lib/elementary/elc_popup.c | 2 +- src/lib/elementary/elm_box.c | 4 ++-- src/lib/elementary/elm_flip.c | 2 +- src/lib/elementary/elm_genlist.c | 2 +- src/lib/elementary/elm_grid.c | 4 ++-- src/lib/elementary/elm_layout.c | 24 ++++++++++++------------ src/lib/elementary/elm_mapbuf.c | 2 +- src/lib/elementary/elm_notify.c | 2 +- src/lib/elementary/elm_panel.c | 2 +- src/lib/elementary/elm_scroller.c | 4 ++-- src/lib/elementary/elm_table.c | 2 +- src/lib/elementary/elm_toolbar.c | 6 +++--- src/lib/elementary/elm_widget.c | 2 +- src/lib/elementary/elm_widget.h | 10 ++++++++++ 15 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/lib/elementary/efl_ui_box.c b/src/lib/elementary/efl_ui_box.c index 38c3b17346..0c1f7932c6 100644 --- a/src/lib/elementary/efl_ui_box.c +++ b/src/lib/elementary/efl_ui_box.c @@ -310,7 +310,7 @@ _efl_ui_box_efl_pack_unpack_all(Eo *obj, Efl_Ui_Box_Data *pd) pd->delete_me = EINA_TRUE; bd = evas_object_smart_data_get(wd->resize_obj); EINA_LIST_FOREACH(bd->children, l, opt) - elm_widget_sub_object_del(obj, opt->obj); + _elm_widget_sub_object_redirect_to_top(obj, opt->obj); pd->delete_me = EINA_FALSE; ret = evas_object_box_remove_all(wd->resize_obj, EINA_FALSE); @@ -327,7 +327,7 @@ _efl_ui_box_efl_pack_unpack(Eo *obj, Efl_Ui_Box_Data *pd, Efl_Gfx *subobj) if (evas_object_box_remove(wd->resize_obj, subobj)) { - ret = elm_widget_sub_object_del(obj, subobj); + ret = _elm_widget_sub_object_redirect_to_top(obj, subobj); _sizing_eval(obj, pd); } diff --git a/src/lib/elementary/elc_popup.c b/src/lib/elementary/elc_popup.c index 7eaf31c284..51a6e680dd 100644 --- a/src/lib/elementary/elc_popup.c +++ b/src/lib/elementary/elc_popup.c @@ -834,7 +834,7 @@ _item_icon_unset(Elm_Popup_Item_Data *it) Evas_Object *icon = it->icon; if (!it->icon) return NULL; - elm_widget_sub_object_del(WIDGET(it), icon); + _elm_widget_sub_object_redirect_to_top(WIDGET(it), icon); evas_object_data_del(icon, "_popup_icon_parent_item"); efl_content_unset(efl_part(VIEW(it), CONTENT_PART)); elm_layout_signal_emit(VIEW(it), "elm,state,item,icon,hidden", "elm"); diff --git a/src/lib/elementary/elm_box.c b/src/lib/elementary/elm_box.c index 15a1a14e8e..d7262a86cb 100644 --- a/src/lib/elementary/elm_box.c +++ b/src/lib/elementary/elm_box.c @@ -536,7 +536,7 @@ _elm_box_unpack(Eo *obj, Elm_Box_Data *_pd EINA_UNUSED, Evas_Object *subobj) ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); if (evas_object_box_remove(wd->resize_obj, subobj)) - elm_widget_sub_object_del(obj, subobj); + _elm_widget_sub_object_redirect_to_top(obj, subobj); } EOLIAN static void @@ -551,7 +551,7 @@ _elm_box_unpack_all(Eo *obj, Elm_Box_Data *pd) pd->delete_me = EINA_TRUE; bd = evas_object_smart_data_get(wd->resize_obj); EINA_LIST_FOREACH (bd->children, l, opt) - elm_widget_sub_object_del(obj, opt->obj); + _elm_widget_sub_object_redirect_to_top(obj, opt->obj); pd->delete_me = EINA_FALSE; /* EINA_FALSE means do not delete objects */ diff --git a/src/lib/elementary/elm_flip.c b/src/lib/elementary/elm_flip.c index e9b61a1b8d..adeddd5cfa 100644 --- a/src/lib/elementary/elm_flip.c +++ b/src/lib/elementary/elm_flip.c @@ -1768,7 +1768,7 @@ _flip_content_unset(Evas_Object *obj, if (!*cont) return NULL; content = *cont; - elm_widget_sub_object_del(obj, content); + _elm_widget_sub_object_redirect_to_top(obj, content); return content; } diff --git a/src/lib/elementary/elm_genlist.c b/src/lib/elementary/elm_genlist.c index e48a5f0186..3ec4cab877 100644 --- a/src/lib/elementary/elm_genlist.c +++ b/src/lib/elementary/elm_genlist.c @@ -7042,7 +7042,7 @@ _elm_genlist_item_all_contents_unset(Eo *eo_item EINA_UNUSED, Elm_Gen_Item *it, EINA_LIST_FREE(it->contents, content) { - elm_widget_sub_object_del(WIDGET(it), content); + _elm_widget_sub_object_redirect_to_top(WIDGET(it), content); edje_object_part_unswallow(VIEW(it), content); evas_object_hide(content); if (l) *l = eina_list_append(*l, content); diff --git a/src/lib/elementary/elm_grid.c b/src/lib/elementary/elm_grid.c index 880eebccc9..7ab8359fbc 100644 --- a/src/lib/elementary/elm_grid.c +++ b/src/lib/elementary/elm_grid.c @@ -205,7 +205,7 @@ _elm_grid_unpack(Eo *obj, void *_pd EINA_UNUSED, Evas_Object *subobj) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); - elm_widget_sub_object_del(obj, subobj); + _elm_widget_sub_object_redirect_to_top(obj, subobj); evas_object_grid_unpack(wd->resize_obj, subobj); } @@ -221,7 +221,7 @@ _elm_grid_clear(Eo *obj, void *_pd EINA_UNUSED, Eina_Bool clear) { chld = evas_object_grid_children_get(wd->resize_obj); EINA_LIST_FREE(chld, o) - elm_widget_sub_object_del(obj, o); + _elm_widget_sub_object_redirect_to_top(obj, o); } evas_object_grid_clear(wd->resize_obj, clear); diff --git a/src/lib/elementary/elm_layout.c b/src/lib/elementary/elm_layout.c index 9aab7bc233..043bb3ebb5 100644 --- a/src/lib/elementary/elm_layout.c +++ b/src/lib/elementary/elm_layout.c @@ -699,7 +699,7 @@ _sub_box_remove(Evas_Object *obj, (wd->resize_obj, sub_d->part, child); _eo_unparent_helper(child, obj); - if (!elm_widget_sub_object_del(obj, child)) + if (!_elm_widget_sub_object_redirect_to_top(obj, child)) { ERR("could not remove sub object %p from %p", child, obj); return NULL; @@ -739,7 +739,7 @@ _sub_table_remove(Evas_Object *obj, _eo_unparent_helper(child, obj); - if (!elm_widget_sub_object_del(obj, child)) + if (!_elm_widget_sub_object_redirect_to_top(obj, child)) { ERR("could not remove sub object %p from %p", child, obj); return NULL; @@ -1008,7 +1008,7 @@ _elm_layout_content_set(Eo *obj, Elm_Layout_Smart_Data *sd, const char *part, Ev * edje_object_part_swallow()'s behavior, then */ else if (content == sub_d->obj) { - elm_widget_sub_object_del(obj, content); + _elm_widget_sub_object_redirect_to_top(obj, content); break; } } @@ -1023,7 +1023,7 @@ _elm_layout_content_set(Eo *obj, Elm_Layout_Smart_Data *sd, const char *part, Ev (wd->resize_obj, part, content)) { ERR("could not swallow %p into part '%s'", content, part); - elm_widget_sub_object_del(obj, content); + _elm_widget_sub_object_redirect_to_top(obj, content); return EINA_FALSE; } @@ -1032,7 +1032,7 @@ _elm_layout_content_set(Eo *obj, Elm_Layout_Smart_Data *sd, const char *part, Ev { ERR("failed to allocate memory!"); edje_object_part_unswallow(wd->resize_obj, content); - elm_widget_sub_object_del(obj, content); + _elm_widget_sub_object_redirect_to_top(obj, content); return EINA_FALSE; } sub_d->type = SWALLOW; @@ -1113,7 +1113,7 @@ _elm_layout_content_unset(Eo *obj, Elm_Layout_Smart_Data *sd, const char *part) content = sub_d->obj; /* sub_d will die in * _elm_layout_smart_sub_object_del */ - if (!elm_widget_sub_object_del(obj, content)) + if (!_elm_widget_sub_object_redirect_to_top(obj, content)) { ERR("could not remove sub object %p from %p", content, obj); return NULL; @@ -1153,7 +1153,7 @@ _elm_layout_efl_container_content_remove(Eo *obj, Elm_Layout_Smart_Data *sd EINA { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); - if (!elm_widget_sub_object_del(obj, content)) + if (!_elm_widget_sub_object_redirect_to_top(obj, content)) { ERR("could not remove sub object %p from %p", content, obj); return EINA_FALSE; @@ -1361,7 +1361,7 @@ _elm_layout_box_append(Eo *obj, Elm_Layout_Smart_Data *sd, const char *part, Eva if (!sub_d) { ERR("failed to allocate memory!"); - elm_widget_sub_object_del(obj, child); + _elm_widget_sub_object_redirect_to_top(obj, child); edje_object_part_box_remove(wd->resize_obj, part, child); return EINA_FALSE; } @@ -1398,7 +1398,7 @@ _elm_layout_box_prepend(Eo *obj, Elm_Layout_Smart_Data *sd, const char *part, Ev if (!sub_d) { ERR("failed to allocate memory!"); - elm_widget_sub_object_del(obj, child); + _elm_widget_sub_object_redirect_to_top(obj, child); edje_object_part_box_remove(wd->resize_obj, part, child); return EINA_FALSE; } @@ -1436,7 +1436,7 @@ _elm_layout_box_insert_before(Eo *obj, Elm_Layout_Smart_Data *sd, const char *pa if (!sub_d) { ERR("failed to allocate memory!"); - elm_widget_sub_object_del(obj, child); + _elm_widget_sub_object_redirect_to_top(obj, child); edje_object_part_box_remove(wd->resize_obj, part, child); return EINA_FALSE; } @@ -1477,7 +1477,7 @@ _elm_layout_box_insert_at(Eo *obj, Elm_Layout_Smart_Data *sd, const char *part, if (!sub_d) { ERR("failed to allocate memory!"); - elm_widget_sub_object_del(obj, child); + _elm_widget_sub_object_redirect_to_top(obj, child); edje_object_part_box_remove(wd->resize_obj, part, child); return EINA_FALSE; } @@ -1569,7 +1569,7 @@ _elm_layout_table_pack(Eo *obj, Elm_Layout_Smart_Data *sd, const char *part, Eva if (!sub_d) { ERR("failed to allocate memory!"); - elm_widget_sub_object_del(obj, child); + _elm_widget_sub_object_redirect_to_top(obj, child); edje_object_part_table_unpack(wd->resize_obj, part, child); return EINA_FALSE; } diff --git a/src/lib/elementary/elm_mapbuf.c b/src/lib/elementary/elm_mapbuf.c index 070dfc6cfa..004bdd3d05 100644 --- a/src/lib/elementary/elm_mapbuf.c +++ b/src/lib/elementary/elm_mapbuf.c @@ -240,7 +240,7 @@ _elm_mapbuf_content_unset(Eo *obj, Elm_Mapbuf_Data *sd, const char *part) if (!sd->content) return NULL; content = sd->content; - elm_widget_sub_object_del(obj, content); + _elm_widget_sub_object_redirect_to_top(obj, content); _elm_mapbuf_content_unset_internal(sd, obj, content); return content; } diff --git a/src/lib/elementary/elm_notify.c b/src/lib/elementary/elm_notify.c index 28d877e314..95d13d84a5 100644 --- a/src/lib/elementary/elm_notify.c +++ b/src/lib/elementary/elm_notify.c @@ -413,7 +413,7 @@ _elm_notify_content_unset(Eo *obj, Elm_Notify_Data *sd, const char *part) if (!sd->content) return NULL; content = sd->content; - elm_widget_sub_object_del(obj, sd->content); + _elm_widget_sub_object_redirect_to_top(obj, sd->content); edje_object_part_unswallow(sd->notify, content); return content; diff --git a/src/lib/elementary/elm_panel.c b/src/lib/elementary/elm_panel.c index 30197b4c90..406e7d36f8 100644 --- a/src/lib/elementary/elm_panel.c +++ b/src/lib/elementary/elm_panel.c @@ -994,7 +994,7 @@ _elm_panel_content_unset(Eo *obj, Elm_Panel_Data *sd, const char *part) evas_object_box_remove_all(sd->bx, EINA_FALSE); if (sd->scrollable) - elm_widget_sub_object_del(sd->scr_ly, sd->content); + _elm_widget_sub_object_redirect_to_top(sd->scr_ly, sd->content); sd->content = NULL; return ret; diff --git a/src/lib/elementary/elm_scroller.c b/src/lib/elementary/elm_scroller.c index 27f710dd6e..2862ae5150 100644 --- a/src/lib/elementary/elm_scroller.c +++ b/src/lib/elementary/elm_scroller.c @@ -827,9 +827,9 @@ _elm_scroller_content_unset(Eo *obj, Elm_Scroller_Data *sd, const char *part) ret = sd->content; if (sd->loop_h || sd->loop_v) - elm_widget_sub_object_del(obj, sd->contents); + _elm_widget_sub_object_redirect_to_top(obj, sd->contents); else - elm_widget_sub_object_del(obj, sd->content); + _elm_widget_sub_object_redirect_to_top(obj, sd->content); elm_interface_scrollable_content_set(obj, NULL); sd->content = NULL; diff --git a/src/lib/elementary/elm_table.c b/src/lib/elementary/elm_table.c index d169f33eec..4eb5489192 100644 --- a/src/lib/elementary/elm_table.c +++ b/src/lib/elementary/elm_table.c @@ -333,7 +333,7 @@ _elm_table_unpack(Eo *obj, void *_pd EINA_UNUSED, Evas_Object *subobj) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); - elm_widget_sub_object_del(obj, subobj); + _elm_widget_sub_object_redirect_to_top(obj, subobj); evas_object_table_unpack(wd->resize_obj, subobj); } diff --git a/src/lib/elementary/elm_toolbar.c b/src/lib/elementary/elm_toolbar.c index b179cb71b8..6dd3be8c5a 100644 --- a/src/lib/elementary/elm_toolbar.c +++ b/src/lib/elementary/elm_toolbar.c @@ -1755,7 +1755,7 @@ _elm_toolbar_item_elm_widget_item_part_content_unset(Eo *eo_item EINA_UNUSED, El } elm_layout_content_unset(VIEW(item), "elm.swallow.object"); - elm_widget_sub_object_del(obj, item->object); + _elm_widget_sub_object_redirect_to_top(obj, item->object); o = item->object; item->object = NULL; scale = (elm_widget_scale_get(obj) * elm_config_scale_get()); @@ -2572,7 +2572,7 @@ _elm_toolbar_item_icon_update(Elm_Toolbar_Item_Data *item) elm_layout_content_get(VIEW(item), "elm.swallow.icon"); Eina_List *l; - elm_widget_sub_object_del(WIDGET(item), old_icon); + _elm_widget_sub_object_redirect_to_top(WIDGET(item), old_icon); elm_layout_content_set(VIEW(item), "elm.swallow.icon", item->icon); if (item->icon) elm_layout_signal_emit(VIEW(item), "elm,state,icon,visible", "elm"); @@ -2642,7 +2642,7 @@ _elm_toolbar_item_icon_obj_set(Evas_Object *obj, (VIEW(item), "elm.swallow.icon_new"); if (old_icon) { - elm_widget_sub_object_del(WIDGET(item), old_icon); + _elm_widget_sub_object_redirect_to_top(WIDGET(item), old_icon); evas_object_hide(old_icon); } elm_layout_content_set diff --git a/src/lib/elementary/elm_widget.c b/src/lib/elementary/elm_widget.c index 73f59745fb..35d9163bd9 100644 --- a/src/lib/elementary/elm_widget.c +++ b/src/lib/elementary/elm_widget.c @@ -1291,7 +1291,7 @@ _elm_widget_sub_object_del(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj } ELM_WIDGET_DATA_GET(sobj, sdc); - sdc->parent_obj = elm_widget_top_get(obj); + sdc->parent_obj = NULL; } if (sd->resize_obj == sobj) sd->resize_obj = NULL; diff --git a/src/lib/elementary/elm_widget.h b/src/lib/elementary/elm_widget.h index e0d5b8e0d5..e99a6433d9 100644 --- a/src/lib/elementary/elm_widget.h +++ b/src/lib/elementary/elm_widget.h @@ -835,6 +835,16 @@ EAPI Eina_Bool _elm_widget_item_onscreen_is(Elm_Object_Item *item); } \ } while (0) +static inline Eina_Bool +_elm_widget_sub_object_redirect_to_top(Evas_Object *obj, Evas_Object *sobj) +{ + Eina_Bool ret = elm_widget_sub_object_del(obj, sobj); + if (ret) + ret = elm_widget_sub_object_add(elm_widget_top_get(obj), sobj); + + return ret; +} + /* to be used by INTERNAL classes on Elementary, so that the widgets * parsing script skips it */ #define ELM_INTERNAL_SMART_SUBCLASS_NEW EVAS_SMART_SUBCLASS_NEW