From 0c78e1eb4d61ae42fcd24a59acef641bb3188636 Mon Sep 17 00:00:00 2001 From: Daniel Zaoui Date: Wed, 9 Nov 2016 07:39:10 +0200 Subject: [PATCH] Toolbar: fix icon switch during state change When many states are set on an item, the icon is deleted when the state is changed. This shouldn't be as it leads to an unstable state whose icon is still considered as existing and errors displayed on the screen. We need to check that the icon is not used inside any state to permit its deletion. Otherwise we should just hide it. @fix --- src/lib/elementary/elm_toolbar.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/elementary/elm_toolbar.c b/src/lib/elementary/elm_toolbar.c index 67f9518091..e9bbc9f02b 100644 --- a/src/lib/elementary/elm_toolbar.c +++ b/src/lib/elementary/elm_toolbar.c @@ -2626,7 +2626,16 @@ _elm_toolbar_item_icon_obj_set(Evas_Object *obj, } if (item->icon) { - evas_object_del(item->icon); + Elm_Toolbar_Item_State *it_state; + Eina_List *l; + Eina_Bool found = EINA_FALSE; + EINA_LIST_FOREACH(item->states, l, it_state) + { + found |= (it_state->icon == item->icon); + } + if (!found) evas_object_del(item->icon); + else evas_object_hide(item->icon); + elm_layout_content_unset(VIEW(item), "elm.swallow.icon"); } item->icon = icon_obj;