From: Enlightenment S. <no-...@en...> - 2009-10-29 17:58:27
|
Log: Elm slideshow: fix preload and memory leak Author: watchwolf Date: 2009-10-29 10:58:16 -0700 (Thu, 29 Oct 2009) New Revision: 43340 Modified: trunk/TMP/st/elementary/src/lib/elm_slideshow.c Modified: trunk/TMP/st/elementary/src/lib/elm_slideshow.c =================================================================== --- trunk/TMP/st/elementary/src/lib/elm_slideshow.c 2009-10-29 17:26:52 UTC (rev 43339) +++ trunk/TMP/st/elementary/src/lib/elm_slideshow.c 2009-10-29 17:58:16 UTC (rev 43340) @@ -21,7 +21,7 @@ { Evas_Object *obj; - Eina_List *l; + Eina_List *l, *l_built; const void *data; const Elm_Slideshow_Item_Class *itc; @@ -63,6 +63,7 @@ elm_slideshow_clear(obj); _stringlist_free(wd->transitions); if (wd->timer) ecore_timer_del(wd->timer); + free(wd); } @@ -119,7 +120,8 @@ edje_object_part_unswallow(NULL, item->o); evas_object_hide(item->o); } - + wd->previous = NULL; + item = wd->current; if(!item || !item->o) return; @@ -151,8 +153,11 @@ { item->o = item->itc->func.get((void*)item->data, obj); evas_object_smart_member_add(item->o, obj); - wd->items_built = eina_list_append(wd->items_built, item); + item->l_built = eina_list_append(NULL, item); + wd->items_built = eina_list_merge(wd->items_built, item->l_built); } + else if(item->l_built) + wd->items_built = eina_list_demote_list(wd->items_built, item->l_built); //we pre built the next and the previous item _item = eina_list_data_get(eina_list_prev(item->l)); @@ -163,9 +168,13 @@ _item->o = _item->itc->func.get((void*)_item->data, obj); evas_object_hide(_item->o); evas_object_smart_member_add(_item->o, obj); - wd->items_built = eina_list_append(wd->items_built, _item); + _item->l_built = eina_list_append(NULL, _item); + wd->items_built = eina_list_merge(wd->items_built, _item->l_built); } + else if(_item && _item->l_built) + wd->items_built = eina_list_demote_list(wd->items_built, _item->l_built); + _item = eina_list_data_get(eina_list_next(item->l)); if(!_item && wd->loop) _item = eina_list_data_get(wd->items); @@ -174,15 +183,21 @@ _item->o = _item->itc->func.get((void*)_item->data, obj); evas_object_hide(_item->o); evas_object_smart_member_add(_item->o, obj); - wd->items_built = eina_list_append(wd->items_built, _item); + _item->l_built = eina_list_append(NULL, _item); + wd->items_built = eina_list_merge(wd->items_built, _item->l_built); } + else if(_item && _item->l_built) + wd->items_built = eina_list_demote_list(wd->items_built, _item->l_built); //only the three last items are keep while(eina_list_count(wd->items_built) > 3) { _item = eina_list_data_get(wd->items_built); wd->items_built = eina_list_remove_list(wd->items_built, wd->items_built); - evas_object_del(_item->o); + if(item->itc->func.del) + item->itc->func.del((void*)item->data, wd->previous->o); + else + evas_object_del(item->o); _item->o = NULL; } } @@ -468,13 +483,17 @@ wd->previous = NULL; wd->current = NULL; - EINA_LIST_FREE(wd->items, item) + + EINA_LIST_FREE(wd->items_built, item) { - if(item->o && item->itc->func.del) - item->itc->func.del((void*)item->data, wd->previous->o); - else if(item->o) + if(item->itc->func.del) + item->itc->func.del((void*)item->data, wd->previous->o); + else evas_object_del(item->o); + } + EINA_LIST_FREE(wd->items, item) + { free(item); } } |