From aa5414f95d37e285b4af5a5f080daf8f900b9e99 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Tue, 21 Feb 2017 22:04:10 +0900 Subject: [PATCH] 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! --- src/lib/elementary/elm_genlist.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/elementary/elm_genlist.c b/src/lib/elementary/elm_genlist.c index a04edbbd80..e624afe96f 100644 --- a/src/lib/elementary/elm_genlist.c +++ b/src/lib/elementary/elm_genlist.c @@ -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));