From e4e5ccb34d9edc62c3310c45adafdda72e1c927f Mon Sep 17 00:00:00 2001 From: Daniel Zaoui Date: Sun, 17 May 2015 14:59:06 +0300 Subject: [PATCH] SlideShow: Fix double invocation of ItemClass delete function When closing the application, the delete function given by the user in the Item Class was called twice. During the clear process, the function was called for every built item and then during the item destruction. This patch fixes this behaviour by calling the user function only during the item destruction. Another fix has been added. It zero'es the built list pointer inside the item. Without this fix, the item points to a list node that is already freed and can lead during widget deletion to an invalid access inside the list. @fix T2394 --- legacy/elementary/src/lib/elm_slideshow.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/legacy/elementary/src/lib/elm_slideshow.c b/legacy/elementary/src/lib/elm_slideshow.c index aae7150fdc..08fd69901d 100644 --- a/legacy/elementary/src/lib/elm_slideshow.c +++ b/legacy/elementary/src/lib/elm_slideshow.c @@ -238,6 +238,7 @@ _item_realize(Elm_Slideshow_Item_Data *item) if (item->itc->func.del) item->itc->func.del(elm_object_item_data_get(EO_OBJ(item)), VIEW(item)); ELM_SAFE_FREE(VIEW(item), evas_object_del); + item->l_built = NULL; } } @@ -628,19 +629,13 @@ _elm_slideshow_loop_get(Eo *obj EINA_UNUSED, Elm_Slideshow_Data *sd) EOLIAN static void _elm_slideshow_clear(Eo *obj EINA_UNUSED, Elm_Slideshow_Data *sd) { - Elm_Slideshow_Item_Data *item; Eo *eo_item; - + Eina_List *itr, *itr2; sd->previous = NULL; sd->current = NULL; - EINA_LIST_FREE(sd->items_built, item) - { - if (item->itc->func.del) - item->itc->func.del(elm_object_item_data_get(EO_OBJ(item)), VIEW(item)); - } - EINA_LIST_FREE(sd->items, eo_item) - eo_del(eo_item); + EINA_LIST_FOREACH_SAFE(sd->items, itr, itr2, eo_item) + eo_del(eo_item); } EOLIAN static const Eina_List*