aboutsummaryrefslogtreecommitdiffstats
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
parentFix memory leak issue on genlist_example_02 (diff)
downloadefl-8d8d08effa3b373a00447a90f0ed301195063159.tar.gz
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 64f5542169..9f48f35a49 100644
--- a/src/lib/elementary/elm_genlist.c
+++ b/src/lib/elementary/elm_genlist.c
@@ -34,6 +34,7 @@
#define MULTI_DOWN_TIME 1.0
#define SWIPE_TIME 0.4
#define SCR_HOLD_TIME 0.1
+#define ITEM_QUEUE_MAX 128
#define ERR_ABORT(_msg) \
do { \
@@ -4626,7 +4627,7 @@ _queue_process(Elm_Genlist_Data *sd)
double t0, t;
t0 = ecore_time_get();
- for (n = 0; (sd->queue) && (n < 128); n++)
+ for (n = 0; (sd->queue) && (n < ITEM_QUEUE_MAX); n++)
{
Elm_Gen_Item *it;
@@ -7549,7 +7550,7 @@ _item_filtered_get(Elm_Gen_Item *it)
{
l = eina_list_data_find_list(sd->filter_queue, it);
if (l)
- sd->filter_queue = eina_list_remove_list(sd->queue, l);
+ sd->filter_queue = eina_list_remove_list(sd->filter_queue, l);
l = eina_list_data_find_list(sd->queue, it);
if (l)
{
@@ -7572,27 +7573,30 @@ static int
_filter_queue_process(Elm_Genlist_Data *sd)
{
int n;
- Elm_Gen_Item *it;
+ Elm_Gen_Item *it, *first;
double t0;
- t0 = ecore_loop_time_get();
- for (n = 0; (sd->filter_queue) && (sd->processed_count < sd->item_count); n++)
+ t0 = ecore_time_get();
+ for (n = 0; ((sd->filter_queue) && (sd->processed_count < ITEM_QUEUE_MAX)); n++)
{
it = eina_list_data_get(sd->filter_queue);
//FIXME: This is added as a fail safe code for items not yet processed.
- while (it->item->queued)
+ while (it && it->item->queued)
{
- if ((ecore_loop_time_get() - t0) > (ecore_animator_frametime_get()))
+ if ((ecore_time_get() - t0) > (ecore_animator_frametime_get()))
return n;
sd->filter_queue = eina_list_remove_list
(sd->filter_queue, sd->filter_queue);
sd->filter_queue = eina_list_append(sd->filter_queue, it);
it = eina_list_data_get(sd->filter_queue);
+
+ //Do not iterate more than one loop
+ if (it == first) return n;
}
sd->filter_queue = eina_list_remove_list(sd->filter_queue, sd->filter_queue);
_filter_item_internal(it);
it->item->block->changed = EINA_TRUE;
- if ((ecore_loop_time_get() - t0) > (ecore_animator_frametime_get()))
+ if ((ecore_time_get() - t0) > (ecore_animator_frametime_get()))
{
//At least 1 item is filtered by this time, so return n+1 for first loop
n++;