genlist: Fix insert after with a tree

This fixes a case where inserting item "C" after item "B" in this
tree would go wrong:

A
B
- 1
- 2

Before this patch, 1 and 2 lose their parent:

A
B
C
- 1
- 2

After this patch, 1 and 2 retain their parent:

A
B
- 1
- 2
C

Insert before worked by luck, no need to fix it.
Note that this patch may require the next one to actually
work (ensuring expanded state flag).

NOTE: This is a behaviour break!
This commit is contained in:
Jean-Philippe Andre 2017-02-21 22:04:10 +09:00
parent fe6bdf30cd
commit aa5414f95d
1 changed files with 6 additions and 0 deletions

View File

@ -6356,6 +6356,12 @@ _elm_genlist_item_insert_after(Eo *obj EINA_UNUSED, Elm_Genlist_Data *sd, const
it->parent->item->items =
eina_list_append_relative(it->parent->item->items, EO_OBJ(it), eo_after);
}
if (after->item->items && after->item->expanded)
{
eo_after = eina_list_last_data_get(after->item->items);
after = efl_data_scope_get(eo_after, ELM_GENLIST_ITEM_CLASS);
}
sd->items = eina_inlist_append_relative
(sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));