This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository efl.

View the commit online.

commit 64793e6cead01274b1f8c64f35812537a39d1a6d
Author: Cedric BAIL <[email protected]>
AuthorDate: Tue Nov 10 17:41:36 2026 -0600

    elementary: collection_view: a released row keeps its Exact_Model size
    
    The idle cleanup drops the row models that are far from the visible
    range, but the position manager keeps the sizes it cached for them. A
    jump back to such rows asked the view for their sizes before their
    models were fetched, and the view answered with the stand-in size: the
    position manager logged 'Reported sizes changed during caching and
    placement' and placed a frame with the wrong sizes. An Exact_Model
    remembers the sizes it was told, so the view now asks it for a row that
    is not in its cache.
    
    The Exact_Model is looked for under the wrappers the view puts around
    the model (the Select_Model, the Homogeneous_Model, the Average_Model).
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/lib/elementary/efl_ui_collection_view.c        |  11 ++
 src/lib/elementary/efl_ui_exact_model.c            | 120 +++++++++++++--------
 src/lib/elementary/elm_priv.h                      |   3 +
 src/tests/elementary/efl_ui_test_collection_view.c |  59 ++++++++++
 4 files changed, 149 insertions(+), 44 deletions(-)

diff --git a/src/lib/elementary/efl_ui_collection_view.c b/src/lib/elementary/efl_ui_collection_view.c
index b5661db440..69ec22d7a6 100644
--- a/src/lib/elementary/efl_ui_collection_view.c
+++ b/src/lib/elementary/efl_ui_collection_view.c
@@ -939,6 +939,17 @@ _cache_size_fetch(Eina_List *requests, Efl_Ui_Collection_Request **request,
    return requests;
 
  not_found:
+   /* A row let go of is still of the size it was told to be, and the
+      position manager has that size cached: saying anything else makes it
+      find the sizes changed under it. An Exact_Model remembers them. */
+   if (_efl_ui_exact_model_row_size_get(pd->model, search_index, &item_size))
+     {
+        target->size = item_size;
+        target->element_depth = 0;
+        target->depth_leader = EINA_FALSE;
+        return requests;
+     }
+
    requests = _request_add(requests, request, search_index, EINA_FALSE);
 
    target->size = item_size;
diff --git a/src/lib/elementary/efl_ui_exact_model.c b/src/lib/elementary/efl_ui_exact_model.c
index 05e2c8d854..e2e64106f0 100644
--- a/src/lib/elementary/efl_ui_exact_model.c
+++ b/src/lib/elementary/efl_ui_exact_model.c
@@ -207,83 +207,84 @@ _efl_ui_exact_model_buffer_expand(unsigned int list_index, unsigned int *buffer,
 }
 
 static unsigned char
-_efl_ui_exact_model_slot_find(Efl_Ui_Exact_Model_Data *pd, unsigned int index,
+_efl_ui_exact_model_slot_find(Efl_Ui_Exact_Model_Data *root, unsigned int index,
                               Eina_Bool width_get, Eina_Bool height_get)
 {
    unsigned char lookup;
-   unsigned char found = EINA_C_ARRAY_LENGTH(pd->parent->slot);
+   unsigned char found = EINA_C_ARRAY_LENGTH(root->slot);
 
-   for (lookup = 0; lookup < EINA_C_ARRAY_LENGTH(pd->parent->slot); lookup++)
+   for (lookup = 0; lookup < EINA_C_ARRAY_LENGTH(root->slot); lookup++)
      {
         // Check if the slot has valid content
-        if (!pd->parent->slot[lookup].defined)
+        if (!root->slot[lookup].defined)
           continue;
         // (start_offset is a block number, not a row index)
-        if (pd->parent->slot[lookup].start_offset == index / EFL_UI_EXACT_MODEL_CONTENT)
+        if (root->slot[lookup].start_offset == index / EFL_UI_EXACT_MODEL_CONTENT)
           found = lookup;
         // Reduce usage to find unused slot.
-        if (pd->parent->slot[lookup].usage > 0)
-          pd->parent->slot[lookup].usage--;
+        if (root->slot[lookup].usage > 0)
+          root->slot[lookup].usage--;
      }
 
    // Do we need to find a new slot?
-   if (found == EINA_C_ARRAY_LENGTH(pd->parent->slot))
+   if (found == EINA_C_ARRAY_LENGTH(root->slot))
      {
         found = 0;
-        for (lookup = 0; lookup < EINA_C_ARRAY_LENGTH(pd->parent->slot); lookup++)
+        for (lookup = 0; lookup < EINA_C_ARRAY_LENGTH(root->slot); lookup++)
           {
-             if (!pd->parent->slot[lookup].defined)
+             if (!root->slot[lookup].defined)
                {
                   // Found an empty slot, let's use that.
                   found = lookup;
                   break;
                }
-             if (pd->parent->slot[lookup].usage < pd->parent->slot[found].usage)
+             if (root->slot[lookup].usage < root->slot[found].usage)
                found = lookup;
           }
 
         // Commit change back to the stored buffer list
-        if (pd->parent->slot[found].defined &&
-            (pd->parent->slot[found].width ||
-             pd->parent->slot[found].height))
+        if (root->slot[found].defined &&
+            (root->slot[found].width ||
+             root->slot[found].height))
           {
-             unsigned int block = pd->parent->slot[found].start_offset;
+             // (written back under the block it holds, not the one that evicts it)
+             unsigned int block = root->slot[found].start_offset;
 
-             if (pd->parent->slot[found].width &&
-                 pd->parent->slot[found].decompressed.width)
-               pd->parent->compressed.width = _efl_ui_exact_model_slot_compress(block,
-                                                                                pd->parent->compressed.width,
-                                                                                pd->parent->slot[found].width);
-             if (pd->parent->slot[found].height &&
-                 pd->parent->slot[found].decompressed.height)
-               pd->parent->compressed.height = _efl_ui_exact_model_slot_compress(block,
-                                                                                 pd->parent->compressed.height,
-                                                                                 pd->parent->slot[found].height);
+             if (root->slot[found].width &&
+                 root->slot[found].decompressed.width)
+               root->compressed.width =
+                 _efl_ui_exact_model_slot_compress(block, root->compressed.width,
+                                                   root->slot[found].width);
+             if (root->slot[found].height &&
+                 root->slot[found].decompressed.height)
+               root->compressed.height =
+                 _efl_ui_exact_model_slot_compress(block, root->compressed.height,
+                                                   root->slot[found].height);
           }
 
-        pd->parent->slot[found].defined = EINA_TRUE;
-        pd->parent->slot[found].decompressed.width = EINA_FALSE;
-        pd->parent->slot[found].decompressed.height = EINA_FALSE;
-        pd->parent->slot[found].start_offset = index / EFL_UI_EXACT_MODEL_CONTENT;
+        root->slot[found].defined = EINA_TRUE;
+        root->slot[found].decompressed.width = EINA_FALSE;
+        root->slot[found].decompressed.height = EINA_FALSE;
+        root->slot[found].start_offset = index / EFL_UI_EXACT_MODEL_CONTENT;
      }
 
    // Increase usage of the returned slot for now
-   pd->parent->slot[found].usage++;
+   root->slot[found].usage++;
 
    // Unpack the data if requested
-   if (width_get && !pd->parent->slot[found].decompressed.width)
+   if (width_get && !root->slot[found].decompressed.width)
      {
-        pd->parent->slot[found].width = _efl_ui_exact_model_buffer_expand(pd->parent->slot[found].start_offset,
-                                                                          pd->parent->slot[found].width,
-                                                                          pd->parent->compressed.width);
-        pd->parent->slot[found].decompressed.width = EINA_TRUE;
+        root->slot[found].width = _efl_ui_exact_model_buffer_expand(root->slot[found].start_offset,
+                                                                    root->slot[found].width,
+                                                                    root->compressed.width);
+        root->slot[found].decompressed.width = EINA_TRUE;
      }
-   if (height_get && !pd->parent->slot[found].decompressed.height)
+   if (height_get && !root->slot[found].decompressed.height)
      {
-        pd->parent->slot[found].height = _efl_ui_exact_model_buffer_expand(pd->parent->slot[found].start_offset,
-                                                                          pd->parent->slot[found].height,
-                                                                          pd->parent->compressed.height);
-        pd->parent->slot[found].decompressed.height = EINA_TRUE;
+        root->slot[found].height = _efl_ui_exact_model_buffer_expand(root->slot[found].start_offset,
+                                                                     root->slot[found].height,
+                                                                     root->compressed.height);
+        root->slot[found].decompressed.height = EINA_TRUE;
      }
 
    return found;
@@ -304,7 +305,7 @@ _efl_ui_exact_model_efl_model_property_set(Eo *obj, Efl_Ui_Exact_Model_Data *pd,
             // (no index: the row left while a slice held it, and has no slot)
             if (index == 0xFFFFFFFF)
               return efl_loop_future_rejected(obj, EFL_MODEL_ERROR_INCORRECT_VALUE);
-            found = _efl_ui_exact_model_slot_find(pd, index, EINA_TRUE, EINA_FALSE);
+            found = _efl_ui_exact_model_slot_find(pd->parent, index, EINA_TRUE, EINA_FALSE);
             if (!eina_value_uint_convert(value, &size) || (size & EFL_UI_EXACT_MODEL_MEASURED))
               return efl_loop_future_rejected(obj, EFL_MODEL_ERROR_INCORRECT_VALUE);
             pd->parent->slot[found].width[index % EFL_UI_EXACT_MODEL_CONTENT] =
@@ -324,7 +325,7 @@ _efl_ui_exact_model_efl_model_property_set(Eo *obj, Efl_Ui_Exact_Model_Data *pd,
             index = efl_composite_model_index_get(obj);
             if (index == 0xFFFFFFFF)
               return efl_loop_future_rejected(obj, EFL_MODEL_ERROR_INCORRECT_VALUE);
-            found = _efl_ui_exact_model_slot_find(pd, index, EINA_FALSE, EINA_TRUE);
+            found = _efl_ui_exact_model_slot_find(pd->parent, index, EINA_FALSE, EINA_TRUE);
             cell = &pd->parent->slot[found].height[index % EFL_UI_EXACT_MODEL_CONTENT];
             old_value = *cell & ~EFL_UI_EXACT_MODEL_MEASURED;
             if (!eina_value_uint_convert(value, &size) || (size & EFL_UI_EXACT_MODEL_MEASURED))
@@ -375,7 +376,7 @@ _efl_ui_exact_model_efl_model_property_get(const Eo *obj, Efl_Ui_Exact_Model_Dat
              index = efl_composite_model_index_get(obj);
              // (no index: the row left while a slice held it, and has no size)
              if (index == 0xFFFFFFFF) return eina_value_error_new(EAGAIN);
-             found = _efl_ui_exact_model_slot_find(pd, index, EINA_TRUE, EINA_FALSE);
+             found = _efl_ui_exact_model_slot_find(pd->parent, index, EINA_TRUE, EINA_FALSE);
              size = pd->parent->slot[found].width[index % EFL_UI_EXACT_MODEL_CONTENT];
              // Not measured yet: not ready, as for a Homogeneous_Model, and not a size of 0.
              if (!(size & EFL_UI_EXACT_MODEL_MEASURED)) return eina_value_error_new(EAGAIN);
@@ -388,7 +389,7 @@ _efl_ui_exact_model_efl_model_property_get(const Eo *obj, Efl_Ui_Exact_Model_Dat
 
              index = efl_composite_model_index_get(obj);
              if (index == 0xFFFFFFFF) return eina_value_error_new(EAGAIN);
-             found = _efl_ui_exact_model_slot_find(pd, index, EINA_FALSE, EINA_TRUE);
+             found = _efl_ui_exact_model_slot_find(pd->parent, index, EINA_FALSE, EINA_TRUE);
              size = pd->parent->slot[found].height[index % EFL_UI_EXACT_MODEL_CONTENT];
              if (!(size & EFL_UI_EXACT_MODEL_MEASURED)) return eina_value_error_new(EAGAIN);
              return eina_value_uint_new(size & ~EFL_UI_EXACT_MODEL_MEASURED);
@@ -415,4 +416,35 @@ _efl_ui_exact_model_efl_model_property_get(const Eo *obj, Efl_Ui_Exact_Model_Dat
    return efl_model_property_get(efl_super(obj, EFL_UI_EXACT_MODEL_CLASS), property);
 }
 
+/* The size of a row as it was told to the model, without the row itself:
+   the view asks for rows it has let go of and cannot wait for them. */
+Eina_Bool
+_efl_ui_exact_model_row_size_get(Efl_Model *model, unsigned int index, Eina_Size2D *size)
+{
+   Efl_Ui_Exact_Model_Data *root;
+   unsigned int w, h;
+   unsigned char found;
+
+   /* The view wraps the model it is given in models of its own. */
+   while (model && !efl_isa(model, EFL_UI_EXACT_MODEL_CLASS))
+     {
+        if (!efl_isa(model, EFL_COMPOSITE_MODEL_CLASS) ||
+            !efl_isa(model, EFL_UI_VIEW_INTERFACE))
+          return EINA_FALSE;
+        model = efl_ui_view_model_get(model);
+     }
+   if (!model) return EINA_FALSE;
+   root = efl_data_scope_get(model, EFL_UI_EXACT_MODEL_CLASS);
+   if (!root || root->parent) return EINA_FALSE;
+
+   found = _efl_ui_exact_model_slot_find(root, index, EINA_TRUE, EINA_TRUE);
+   w = root->slot[found].width[index % EFL_UI_EXACT_MODEL_CONTENT];
+   h = root->slot[found].height[index % EFL_UI_EXACT_MODEL_CONTENT];
+   if (!(w & EFL_UI_EXACT_MODEL_MEASURED) || !(h & EFL_UI_EXACT_MODEL_MEASURED))
+     return EINA_FALSE;
+   size->w = w & ~EFL_UI_EXACT_MODEL_MEASURED;
+   size->h = h & ~EFL_UI_EXACT_MODEL_MEASURED;
+   return EINA_TRUE;
+}
+
 #include "efl_ui_exact_model.eo.c"
diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h
index 32aa36b1fa..dbe3381774 100644
--- a/src/lib/elementary/elm_priv.h
+++ b/src/lib/elementary/elm_priv.h
@@ -653,6 +653,9 @@ struct _Elm_Module
    int          references;
 };
 
+Eina_Bool            _efl_ui_exact_model_row_size_get(Efl_Model *model,
+                                                      unsigned int index,
+                                                      Eina_Size2D *size);
 Eina_Bool            _elm_web_init(const char *engine);
 
 Eo                   *_elm_atspi_bridge_get(void);
diff --git a/src/tests/elementary/efl_ui_test_collection_view.c b/src/tests/elementary/efl_ui_test_collection_view.c
index a26524de73..bd58b1b5da 100644
--- a/src/tests/elementary/efl_ui_test_collection_view.c
+++ b/src/tests/elementary/efl_ui_test_collection_view.c
@@ -980,6 +980,64 @@ EFL_START_TEST(test_efl_ui_collection_view_remove_last_row)
 }
 EFL_END_TEST
 
+/* A list of rows measured, jumped far away and back, beyond the rows kept
+   around the visible ones: the rows let go of are still of the size they
+   were measured at, and the position manager must not be told otherwise
+   (it logs the sizes changing under it) nor place the rows by it. */
+EFL_START_TEST(test_efl_ui_collection_view_exact_model_jump)
+{
+   Efl_Ui_Win *win;
+   Efl_Model *sizes;
+   Efl_Ui_List_View *lv;
+   Eina_List *realized = NULL;
+   Efl_Gfx_Entity *item;
+   Eina_Rect g;
+   int errors = 0, i, y = 0;
+   const int target = 40;
+
+   win = win_add(NULL, "win", EFL_UI_WIN_TYPE_BASIC);
+   efl_gfx_entity_size_set(win, EINA_SIZE2D(200, 100));
+   eina_log_print_cb_set(_count_err_cri, &errors);
+
+   lv = _exact_list(win, &sizes);
+   efl_event_callback_add(lv, EFL_UI_COLLECTION_VIEW_EVENT_ITEM_REALIZED,
+                          _realized_track, &realized);
+   efl_event_callback_add(lv, EFL_UI_COLLECTION_VIEW_EVENT_ITEM_UNREALIZED,
+                          _unrealized_track, &realized);
+   get_me_to_those_events(lv);
+   for (i = 0; i < 50; i++)
+     {
+        ecore_main_loop_iterate();
+     }
+
+   for (i = 0; i < target; i++)
+     {
+        y += (i % 2) ? 40 : 90;
+     }
+   efl_ui_scrollable_content_pos_set(lv, EINA_POSITION2D(0, y));
+   wait_timer(0.5);
+   efl_ui_scrollable_content_pos_set(lv, EINA_POSITION2D(0, 0));
+   wait_timer(0.5);
+   efl_ui_scrollable_content_pos_set(lv, EINA_POSITION2D(0, y));
+   wait_timer(0.5);
+
+   eina_log_print_cb_set(eina_log_print_cb_stderr, NULL);
+   ck_assert_int_eq(errors, 0);
+
+   item = _realized_row(realized, target);
+   ck_assert_ptr_nonnull(item);
+   g = efl_gfx_entity_geometry_get(item);
+   ck_assert_int_eq(g.h, 90);
+   ck_assert_int_eq(g.y, efl_gfx_entity_position_get(lv).y);
+
+   efl_event_callback_del(lv, EFL_UI_COLLECTION_VIEW_EVENT_ITEM_REALIZED,
+                          _realized_track, &realized);
+   efl_event_callback_del(lv, EFL_UI_COLLECTION_VIEW_EVENT_ITEM_UNREALIZED,
+                          _unrealized_track, &realized);
+   eina_list_free(realized);
+}
+EFL_END_TEST
+
 void efl_ui_test_collection_view(TCase *tc)
 {
    tcase_add_test(tc, test_efl_ui_collection_view_basic);
@@ -999,4 +1057,5 @@ void efl_ui_test_collection_view(TCase *tc)
    tcase_add_test(tc, test_efl_ui_collection_view_item_events_without_info);
    tcase_add_test(tc, test_efl_ui_collection_view_sizes_agree);
    tcase_add_test(tc, test_efl_ui_collection_view_remove_last_row);
+   tcase_add_test(tc, test_efl_ui_collection_view_exact_model_jump);
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to