lorddrew pushed a commit to branch master.

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

commit a2532b8ef0a69b00019d3ea5cf87032de4fdd201
Author: Andrii Kroitor <an.kroi...@samsung.com>
Date:   Wed Nov 15 10:41:45 2017 +0200

    genlist: fix state corruption of content
    
    When using reusable content, genlist preserves old object's state and is
    expecting reusable_content_get callback to change all needed properties.
    But there was an inconsistency: it was silently re-enabling the old content.
    
    @fix
---
 src/bin/elementary/test_genlist.c | 26 +++++++++++++++++++++++---
 src/lib/elementary/elm_genlist.c  |  3 ---
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/bin/elementary/test_genlist.c 
b/src/bin/elementary/test_genlist.c
index 789b7b0486..7db692034a 100644
--- a/src/bin/elementary/test_genlist.c
+++ b/src/bin/elementary/test_genlist.c
@@ -5537,23 +5537,43 @@ gl_re2_reusable_content_get(void *data, Evas_Object 
*obj,
    int num = (int)(uintptr_t)data;
    char buf[64];
 
+   // Returning NULL from this callback means that content_get should be used 
instead.
+   // In this case if old object is not NULL, it will be deleted by genlist.
    if (!enabled || !old)
      return NULL;
 
+   // Genlist preserves whole state of the old content.
+   // But we don't know for which item it was used before. We know only that
+   // the old item had same item_class, same tree mode and that content was 
created for "part".
+   // This means that we should apply all item-specific properties to the old 
object.
    if (!strcmp(part, "elm.swallow.icon"))
      {
         printf("REUSING content (icon) for item # %d\n", num);
-        snprintf(buf, sizeof(buf), "Content for item # %d", num);
+        // No need to change color, because all contents for "elm.swallow.icon"
+        // have same red color
+        snprintf(buf, sizeof(buf), "Reused content for item # %d", num);
+        // But we need to set correct text, because it's different for 
different items
         elm_object_text_set(old, buf);
+        // Object is ready for use.
         return old;
      }
 
    if (!strcmp(part, "elm.swallow.end"))
      {
         printf("REUSING content (end) for item # %d\n", num);
-        snprintf(buf, sizeof(buf), "Content for item # %d", num);
+        // Also not changing color, it's already correct.
+        snprintf(buf, sizeof(buf), "Reused content for item # %d", num);
+        // Updating text.
         elm_object_text_set(old, buf);
-        if ((num % 5) == 0) elm_object_disabled_set(old, EINA_TRUE);
+        // Changing disabled state of content:
+        if ((num % 5) == 0)
+          // disabling every 5th item's content in the same way as in 
content_get
+          elm_object_disabled_set(old, EINA_TRUE);
+        else
+          // but also explicitly enabling other contents, because the old 
object
+          // could be disabled if it was used in one of the 5th items 
previously
+          elm_object_disabled_set(old, EINA_FALSE);
+        // Object is ready for use.
         return old;
      }
 
diff --git a/src/lib/elementary/elm_genlist.c b/src/lib/elementary/elm_genlist.c
index 6fb54d3b2b..c2d59bb4c1 100644
--- a/src/lib/elementary/elm_genlist.c
+++ b/src/lib/elementary/elm_genlist.c
@@ -1695,9 +1695,6 @@ _content_cache_add(Elm_Gen_Item *it, Eina_List **cache)
    Evas_Object *content = NULL;
    EINA_LIST_FREE(it->contents, content)
      {
-        if (efl_isa(content, ELM_WIDGET_CLASS) && 
elm_widget_disabled_get(content))
-          elm_widget_disabled_set(content, EINA_FALSE);
-
         *cache = eina_list_append(*cache, content);
         eina_hash_del_by_key(pd->content_item_map, &content);
      }

-- 


Reply via email to