summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSangHyeon Lee <sh10233.lee@samsung.com>2016-07-29 11:21:27 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-07-29 11:29:25 +0900
commit8d8d08effa3b373a00447a90f0ed301195063159 (patch)
treef11ce3efad8e525de344dfc66dd45fec9e466827
parentc7c387b33a4f242c981ca41aacbdc6004b7ce344 (diff)
genlist: fix memory-leak in filter queue and refactoring queue iteration
Summary: There are critical memory-leak in filter queue process. It looks typo so I fix it and refactoring queue iteration logic to spend less time in for and while loop. Test Plan: Tested by filter elementary test Reviewers: shashank0990 Reviewed By: shashank0990 Subscribers: raster, cedric, jpeg Differential Revision: https://phab.enlightenment.org/D4170
-rw-r--r--src/lib/elementary/elm_genlist.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/lib/elementary/elm_genlist.c b/src/lib/elementary/elm_genlist.c
index 64f5542..9f48f35 100644
--- a/src/lib/elementary/elm_genlist.c
+++ b/src/lib/elementary/elm_genlist.c
@@ -34,6 +34,7 @@
34#define MULTI_DOWN_TIME 1.0 34#define MULTI_DOWN_TIME 1.0
35#define SWIPE_TIME 0.4 35#define SWIPE_TIME 0.4
36#define SCR_HOLD_TIME 0.1 36#define SCR_HOLD_TIME 0.1
37#define ITEM_QUEUE_MAX 128
37 38
38#define ERR_ABORT(_msg) \ 39#define ERR_ABORT(_msg) \
39 do { \ 40 do { \
@@ -4626,7 +4627,7 @@ _queue_process(Elm_Genlist_Data *sd)
4626 double t0, t; 4627 double t0, t;
4627 4628
4628 t0 = ecore_time_get(); 4629 t0 = ecore_time_get();
4629 for (n = 0; (sd->queue) && (n < 128); n++) 4630 for (n = 0; (sd->queue) && (n < ITEM_QUEUE_MAX); n++)
4630 { 4631 {
4631 Elm_Gen_Item *it; 4632 Elm_Gen_Item *it;
4632 4633
@@ -7549,7 +7550,7 @@ _item_filtered_get(Elm_Gen_Item *it)
7549 { 7550 {
7550 l = eina_list_data_find_list(sd->filter_queue, it); 7551 l = eina_list_data_find_list(sd->filter_queue, it);
7551 if (l) 7552 if (l)
7552 sd->filter_queue = eina_list_remove_list(sd->queue, l); 7553 sd->filter_queue = eina_list_remove_list(sd->filter_queue, l);
7553 l = eina_list_data_find_list(sd->queue, it); 7554 l = eina_list_data_find_list(sd->queue, it);
7554 if (l) 7555 if (l)
7555 { 7556 {
@@ -7572,27 +7573,30 @@ static int
7572_filter_queue_process(Elm_Genlist_Data *sd) 7573_filter_queue_process(Elm_Genlist_Data *sd)
7573{ 7574{
7574 int n; 7575 int n;
7575 Elm_Gen_Item *it; 7576 Elm_Gen_Item *it, *first;
7576 double t0; 7577 double t0;
7577 7578
7578 t0 = ecore_loop_time_get(); 7579 t0 = ecore_time_get();
7579 for (n = 0; (sd->filter_queue) && (sd->processed_count < sd->item_count); n++) 7580 for (n = 0; ((sd->filter_queue) && (sd->processed_count < ITEM_QUEUE_MAX)); n++)
7580 { 7581 {
7581 it = eina_list_data_get(sd->filter_queue); 7582 it = eina_list_data_get(sd->filter_queue);
7582 //FIXME: This is added as a fail safe code for items not yet processed. 7583 //FIXME: This is added as a fail safe code for items not yet processed.
7583 while (it->item->queued) 7584 while (it && it->item->queued)
7584 { 7585 {
7585 if ((ecore_loop_time_get() - t0) > (ecore_animator_frametime_get())) 7586 if ((ecore_time_get() - t0) > (ecore_animator_frametime_get()))
7586 return n; 7587 return n;
7587 sd->filter_queue = eina_list_remove_list 7588 sd->filter_queue = eina_list_remove_list
7588 (sd->filter_queue, sd->filter_queue); 7589 (sd->filter_queue, sd->filter_queue);
7589 sd->filter_queue = eina_list_append(sd->filter_queue, it); 7590 sd->filter_queue = eina_list_append(sd->filter_queue, it);
7590 it = eina_list_data_get(sd->filter_queue); 7591 it = eina_list_data_get(sd->filter_queue);
7592
7593 //Do not iterate more than one loop
7594 if (it == first) return n;
7591 } 7595 }
7592 sd->filter_queue = eina_list_remove_list(sd->filter_queue, sd->filter_queue); 7596 sd->filter_queue = eina_list_remove_list(sd->filter_queue, sd->filter_queue);
7593 _filter_item_internal(it); 7597 _filter_item_internal(it);
7594 it->item->block->changed = EINA_TRUE; 7598 it->item->block->changed = EINA_TRUE;
7595 if ((ecore_loop_time_get() - t0) > (ecore_animator_frametime_get())) 7599 if ((ecore_time_get() - t0) > (ecore_animator_frametime_get()))
7596 { 7600 {
7597 //At least 1 item is filtered by this time, so return n+1 for first loop 7601 //At least 1 item is filtered by this time, so return n+1 for first loop
7598 n++; 7602 n++;