[Genlist] Fix genlist index get bug
authorTae-Hwan Kim <the81.kim@samsung.com>
Mon, 25 Mar 2013 10:22:44 +0000 (19:22 +0900)
committerSungho Kwak <sungho1.kwak@samsung.com>
Thu, 28 Mar 2013 02:51:04 +0000 (11:51 +0900)
Because not all item block have "max_items_per_block" number of items
in it's block. So the calculation is not correct when items are added &
removed in each block.
Because genlist uses inlinst, there is a performance problem to get
index of genlist item.

Change-Id: Ib5b557fbb194a6f94e45d8c918100c21de42c3a2

src/lib/elm_genlist.c

index 9a24f27..721efae 100644 (file)
@@ -6491,14 +6491,18 @@ elm_genlist_item_cursor_engine_only_get(const Elm_Object_Item *it)
 EAPI int
 elm_genlist_item_index_get(const Elm_Object_Item *item)
 {
+   int cnt = 0;
+   Elm_Gen_Item *tmp;
    Elm_Gen_Item *it = (Elm_Gen_Item *)item;
 
    ELM_GENLIST_ITEM_CHECK_OR_RETURN(item, -1);
 
-   if (it->item->block)
-     return it->position + (it->item->block->position *
-                            GL_IT(it)->wsd->max_items_per_block);
-   return -1;
+   EINA_INLIST_FOREACH(GL_IT(it)->wsd->items, tmp)
+     {
+        if (tmp == it) break;
+        cnt++;
+     }
+   return cnt;
 }
 
 EAPI void