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 e2651811a5388a6189e850696162f4e16fb719e7
Author: Cedric BAIL <[email protected]>
AuthorDate: Mon Nov 9 17:11:18 2026 -0600
elementary: Exact_Model finds size blocks by their own number
A slot holds one block of 1024 rows and start_offset is the block
number, but the lookup compared it with a row index, so rows past the
first block never found their slot. Evicting a slot also wrote it back
under the block of the row that caused the eviction, and the list of
compressed blocks was filled with the wrong number of zero blocks, so
rows read back the height of another block (or crashed on a bad buffer).
Look a slot up by index / 1024, write an evicted slot back under its own
block, and fill the list up to that block only.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/elementary/efl_ui_exact_model.c | 51 +++++++++++----------
src/tests/elementary/efl_ui_model.c | 80 +++++++++++++++++++++++++++++++++
2 files changed, 108 insertions(+), 23 deletions(-)
diff --git a/src/lib/elementary/efl_ui_exact_model.c b/src/lib/elementary/efl_ui_exact_model.c
index 80ddc6464f..3ba2d0e894 100644
--- a/src/lib/elementary/efl_ui_exact_model.c
+++ b/src/lib/elementary/efl_ui_exact_model.c
@@ -55,14 +55,12 @@ _efl_ui_exact_model_efl_object_constructor(Eo *obj, Efl_Ui_Exact_Model_Data *pd)
}
static Eina_List *
-_efl_ui_exact_model_slot_compress(unsigned int index, Eina_List *compressed, unsigned int *buffer)
+_efl_ui_exact_model_slot_compress(unsigned int list_index, Eina_List *compressed, unsigned int *buffer)
{
- unsigned int list_index = index / EFL_UI_EXACT_MODEL_CONTENT;
static Eina_Binbuf *z = NULL;
Eina_Binbuf *cbuf;
Eina_Binbuf *tbuf;
Eina_List *l = NULL;
- unsigned int i;
l = eina_list_nth_list(compressed, list_index);
@@ -73,8 +71,17 @@ _efl_ui_exact_model_slot_compress(unsigned int index, Eina_List *compressed, uns
eina_binbuf_free(tbuf);
if (!cbuf) return compressed;
+ if (l)
+ {
+ // Replace older buffer by newer buffer
+ tbuf = eina_list_data_get(l);
+ eina_list_data_set(l, cbuf);
+ if (tbuf != z) eina_binbuf_free(tbuf);
+ return compressed;
+ }
+
// Make sure the list has all the buffer up to the needed one filled with valid data
- if (list_index)
+ if (eina_list_count(compressed) < list_index)
{
// Create the compressed zero buffer once.
if (!z)
@@ -84,15 +91,15 @@ _efl_ui_exact_model_slot_compress(unsigned int index, Eina_List *compressed, uns
zmem = calloc(EFL_UI_EXACT_MODEL_CONTENT, sizeof (unsigned int));
if (!zmem)
{
- if (cbuf) eina_binbuf_free(cbuf);
+ eina_binbuf_free(cbuf);
return compressed;
}
tbuf = eina_binbuf_manage_new(zmem, EFL_UI_EXACT_MODEL_CONTENT_LENGTH, EINA_TRUE);
if (!tbuf)
{
- if (cbuf) eina_binbuf_free(cbuf);
- if (zmem) free(zmem);
+ eina_binbuf_free(cbuf);
+ free(zmem);
return compressed;
}
@@ -100,23 +107,19 @@ _efl_ui_exact_model_slot_compress(unsigned int index, Eina_List *compressed, uns
eina_binbuf_free(tbuf);
free(zmem);
+ if (!z)
+ {
+ eina_binbuf_free(cbuf);
+ return compressed;
+ }
}
// Fill the list all the way to the needed index with buffer full of zero
- for (i = 0; i < list_index; i++)
- {
- compressed = eina_list_append(compressed, z);
- }
- l = eina_list_last(compressed);
+ while (eina_list_count(compressed) < list_index)
+ compressed = eina_list_append(compressed, z);
}
- // Replace older buffer by newer buffer
- tbuf = eina_list_data_get(l);
- compressed = eina_list_prepend_relative(compressed, l, cbuf);
- compressed = eina_list_remove_list(compressed, l);
- if (tbuf != z) eina_binbuf_free(tbuf);
-
- return compressed;
+ return eina_list_append(compressed, cbuf);
}
static unsigned int *
@@ -157,8 +160,8 @@ _efl_ui_exact_model_slot_find(Efl_Ui_Exact_Model_Data *pd, unsigned int index,
// Check if the slot has valid content
if (!pd->parent->slot[lookup].defined)
continue;
- if (pd->parent->slot[lookup].start_offset <= index &&
- index < pd->parent->slot[lookup].start_offset + EFL_UI_EXACT_MODEL_CONTENT)
+ // (start_offset is a block number, not a row index)
+ if (pd->parent->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)
@@ -186,14 +189,16 @@ _efl_ui_exact_model_slot_find(Efl_Ui_Exact_Model_Data *pd, unsigned int index,
(pd->parent->slot[found].width ||
pd->parent->slot[found].height))
{
+ unsigned int block = pd->parent->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(index,
+ 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(index,
+ pd->parent->compressed.height = _efl_ui_exact_model_slot_compress(block,
pd->parent->compressed.height,
pd->parent->slot[found].height);
}
diff --git a/src/tests/elementary/efl_ui_model.c b/src/tests/elementary/efl_ui_model.c
index 79056a726a..3954dd932d 100644
--- a/src/tests/elementary/efl_ui_model.c
+++ b/src/tests/elementary/efl_ui_model.c
@@ -337,6 +337,85 @@ EFL_START_TEST(efl_ui_average_model_test)
}
EFL_END_TEST
+// Rows past the first block of 1024 are kept in other slots, and a slot that is
+// reused for another block must be written back under its own block.
+#define MANY_ROWS 3500
+
+typedef struct _Many_Rows Many_Rows;
+
+struct _Many_Rows
+{
+ Eo *rows[MANY_ROWS];
+ unsigned int count;
+};
+
+static Eina_Value
+_many_rows_then(void *data, const Eina_Value v, const Eina_Future *dead EINA_UNUSED)
+{
+ Many_Rows *many = data;
+ unsigned int i, len;
+ Eo *c;
+
+ EINA_VALUE_ARRAY_FOREACH(&v, len, i, c)
+ {
+ many->rows[i] = efl_ref(c);
+ many->count++;
+ }
+ return v;
+}
+
+static unsigned int
+_many_height(unsigned int i)
+{
+ return 1 + ((i * 7) % 97) + ((i / 1024) * 100);
+}
+
+EFL_START_TEST(efl_ui_exact_model_many_rows)
+{
+ Efl_Generic_Model *base_model;
+ Efl_Model *model;
+ Many_Rows *many = calloc(1, sizeof (Many_Rows));
+ unsigned int i, step, sum = 0, loops;
+
+ base_model = efl_add_ref(EFL_GENERIC_MODEL_CLASS, efl_main_loop_get());
+ for (i = 0; i < MANY_ROWS; i++)
+ {
+ efl_model_child_add(base_model);
+ }
+ model = efl_add_ref(EFL_UI_EXACT_MODEL_CLASS, efl_main_loop_get(),
+ efl_ui_view_model_set(efl_added, base_model));
+ ck_assert(!!model);
+
+ eina_future_then(efl_model_children_slice_get(model, 0, MANY_ROWS), _many_rows_then, many, NULL);
+ for (loops = 0; (loops < 50) && (many->count < MANY_ROWS); loops++)
+ {
+ ecore_main_loop_iterate();
+ }
+ ck_assert_uint_eq(many->count, MANY_ROWS);
+
+ // scattered: every block is left and come back to many times
+ for (step = 0, i = 0; step < MANY_ROWS; step++, i = (i + 1237) % MANY_ROWS)
+ {
+ efl_future_then(many->rows[i], efl_model_property_set(many->rows[i], "self.height",
+ eina_value_uint_new(_many_height(i))));
+ sum += _many_height(i);
+ }
+ for (step = 0, i = 0; step < MANY_ROWS; step++, i = (i + 1237) % MANY_ROWS)
+ {
+ ck_assert_uint_eq(_property_uint_expected(many->rows[i], "self.height"), _many_height(i));
+ }
+ ck_assert_uint_eq(_property_uint_expected(model, "total.height"), sum);
+
+ for (i = 0; i < MANY_ROWS; i++)
+ {
+ efl_unref(many->rows[i]);
+ }
+ free(many);
+ efl_unref(model);
+ efl_unref(base_model);
+}
+EFL_END_TEST
+
void
efl_ui_model(TCase *tc)
{
@@ -348,4 +427,5 @@ efl_ui_model(TCase *tc)
tcase_add_test(tc, efl_ui_homogeneous_model_test);
tcase_add_test(tc, efl_ui_average_model_test);
tcase_add_test(tc, efl_ui_exact_model_test);
+ tcase_add_test(tc, efl_ui_exact_model_many_rows);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.