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
This commit is contained in:
Daniel Zaoui 2016-11-09 07:39:10 +02:00
parent 7957041d84
commit 0c78e1eb4d
1 changed files with 10 additions and 1 deletions

View File

@ -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;