davemds pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=e88423e9948f0c39d6b16f9c33e7583545e525f1

commit e88423e9948f0c39d6b16f9c33e7583545e525f1
Author: Dave Andreoli <d...@gurumeditation.it>
Date:   Sun Apr 24 11:46:45 2016 +0200

    Genlist: cache mechanism is broken again!
    
    added a new test to show the issue
---
 src/bin/elementary/test.c         |  2 +
 src/bin/elementary/test_genlist.c | 90 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 92 insertions(+)

diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 9fbca60..5f272a0 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -129,6 +129,7 @@ void test_genlist_multi_select(void *data, Evas_Object 
*obj, void *event_info);
 void test_genlist_del(void *data, Evas_Object *obj, void *event_info);
 void test_genlist_filter(void *data, Evas_Object *obj, void *event_info);
 void test_genlist_show_bring(void *data, Evas_Object *obj, void *event_info);
+void test_genlist_cache(void *data, Evas_Object *obj, void *event_info);
 void test_gesture_layer(void *data, Evas_Object *obj, void *event_info);
 void test_gesture_layer2(void *data, Evas_Object *obj, void *event_info);
 void test_gesture_layer3(void *data, Evas_Object *obj, void *event_info);
@@ -706,6 +707,7 @@ add_tests:
    ADD_TEST(NULL, "Lists - Genlist", "Genlist Del", test_genlist_del);
    ADD_TEST(NULL, "Lists - Genlist", "Genlist Filter", test_genlist_filter);
    ADD_TEST(NULL, "Lists - Genlist", "Genlist Show/Bring", 
test_genlist_show_bring);
+   ADD_TEST(NULL, "Lists - Genlist", "Genlist Cache", test_genlist_cache);
 
    //------------------------------//
 
diff --git a/src/bin/elementary/test_genlist.c 
b/src/bin/elementary/test_genlist.c
index 0f8636f..eda321b 100644
--- a/src/bin/elementary/test_genlist.c
+++ b/src/bin/elementary/test_genlist.c
@@ -5003,6 +5003,8 @@ test_genlist_focus(void *data EINA_UNUSED,
    evas_object_show(win);
 }
 
+
+/***  Genlist Filteer  *******************************************************/
 char *genlist_demo_names[] = {
         "Aaliyah", "Aamir", "Aaralyn", "Aaron", "Abagail",
         "Babitha", "Bahuratna", "Bandana", "Bulbul", "Cade", "Caldwell",
@@ -5150,6 +5152,8 @@ test_genlist_filter(void *data EINA_UNUSED,
    evas_object_smart_callback_add(entry, "changed,user", _entry_change_cb, 
api);
 }
 
+
+/***  Genlist Show/BringIN  **************************************************/
 static void
 _rd_changed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
 {
@@ -5302,3 +5306,89 @@ test_genlist_show_bring(void *data EINA_UNUSED,
    evas_object_show(win);
 }
 
+
+/***  Genlist Cache  *********************************************************/
+static char *
+gl_cache_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part 
EINA_UNUSED)
+{
+   char buf[256];
+   int num = (int)(uintptr_t)data;
+
+   if ((num % 2) == 0)
+      snprintf(buf, sizeof(buf),
+               "<align=left> ← only icon  (Item # %d)</align>", num);
+   else
+      snprintf(buf, sizeof(buf),
+               "<align=right>(Item # %d)  only end → </align>", num);
+
+   return strdup(buf);
+}
+
+static Evas_Object *
+gl_cache_content_get(void *data, Evas_Object *obj, const char *part)
+{
+   char buf[PATH_MAX];
+   Evas_Object *ic;
+   Eina_Bool even = (((int)(uintptr_t)data % 2) == 0);
+
+   if (even && !strcmp(part, "elm.swallow.icon"))
+     snprintf(buf, sizeof(buf), "%s/images/bubble.png", 
elm_app_data_dir_get());
+   else if (!even && !strcmp(part, "elm.swallow.end"))
+     snprintf(buf, sizeof(buf), "%s/images/logo_small.png", 
elm_app_data_dir_get());
+   else
+      return NULL;
+
+   ic = elm_icon_add(obj);
+   elm_image_file_set(ic, buf, NULL);
+   evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+   return ic;
+}
+
+void
+test_genlist_cache(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+                   void *event_info EINA_UNUSED)
+{
+   Evas_Object *win, *bx, *fr, *lb, *gl;
+   Elm_Genlist_Item_Class *itc;
+   int i;
+
+   win = elm_win_util_standard_add("genlist-cache", "Genlist Cache");
+   elm_win_autodel_set(win, EINA_TRUE);
+
+   bx = elm_box_add(win);
+   evas_object_size_hint_expand_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   elm_win_resize_object_add(win, bx);
+   evas_object_show(bx);
+
+   fr = elm_frame_add(bx);
+   elm_object_text_set(fr, "Information");
+   elm_box_pack_end(bx, fr);
+   evas_object_show(fr);
+
+   lb = elm_label_add(fr);
+   elm_object_text_set(lb, "Even items should have only the icon (left),<br>"
+                       "while odd items should have only the end icon 
(right)");
+   elm_object_content_set(fr, lb);
+   evas_object_show(lb);
+
+   gl = elm_genlist_add(bx);
+   evas_object_size_hint_expand_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_size_hint_fill_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   elm_box_pack_end(bx, gl);
+   evas_object_show(gl);
+
+   itc = elm_genlist_item_class_new();
+   itc->item_style = "default_style";
+   itc->func.text_get = gl_cache_text_get;
+   itc->func.content_get = gl_cache_content_get;
+
+   for (i = 1; i <= 200; i++)
+       elm_genlist_item_append(gl, itc, (void*)(uintptr_t)i, NULL,
+                               ELM_GENLIST_ITEM_NONE, NULL, NULL);
+
+   elm_genlist_item_class_free(itc);
+
+   evas_object_resize(win, 480, 400);
+   explode_win_enable(win);
+   evas_object_show(win);
+}

-- 


Reply via email to