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 edeae5184a15b76938e2ad4eb02b0ac4b082e341
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 15 22:40:05 2026 -0600
elementary: select_model: a refused unselect of the old row rolls back
In single mode, selecting a row unselects the one selected before, and
the two run side by side through eina_future_all(). That future always
resolves: a member that failed is an error value inside the array. The
array was reduced to the commit of the new row, so a failed unselect of
the old one was dropped, and both rows stayed selected, while the
rollback written for that failure only ran when the whole chain was
cancelled.
The unselect result is now looked at, and an error rolls the select
back as a cancel does: the new row is unselected and the old one stays
the selected and last selected row. A row before that left the model
while the select ran is not selected any more, which is all its
unselect was for, so its error is not a failure.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/elementary/efl_ui_select_model.c | 35 +++++++++----
src/tests/elementary/efl_ui_test_select_model.c | 69 +++++++++++++++++++++++++
2 files changed, 93 insertions(+), 11 deletions(-)
diff --git a/src/lib/elementary/efl_ui_select_model.c b/src/lib/elementary/efl_ui_select_model.c
index 5ccd9b9091..e391db4af3 100644
--- a/src/lib/elementary/efl_ui_select_model.c
+++ b/src/lib/elementary/efl_ui_select_model.c
@@ -471,17 +471,6 @@ _regenerate_error(void *data,
return r;
}
-static Eina_Value
-_untangle_array(void *data EINA_UNUSED,
- const Eina_Value v)
-{
- Eina_Value va = EINA_VALUE_EMPTY;
-
- // Only return the commit change, not the result of the unselect
- eina_value_array_get(&v, 0, &va);
- return va;
-}
-
// What a select that unselects the row selected before keeps to roll back with
typedef struct
{
@@ -549,6 +538,30 @@ _untangle_error(void *data, Eina_Error err)
return _untangle_rollback(data, err);
}
+// The select and the unselect of the row before ran side by side, and both
+// came back as values: return the commit of the select, unless the unselect
+// failed, which is a failure of the select. A row before that has left the
+// model is not selected any more, which is all its unselect was for.
+static Eina_Value
+_untangle_array(void *data, const Eina_Value v)
+{
+ Untangle *u = data;
+ Eina_Value va = EINA_VALUE_EMPTY;
+ Eina_Value unselect = EINA_VALUE_EMPTY;
+ Eina_Error err = 0;
+
+ eina_value_array_get(&v, 0, &va);
+ if (!eina_value_array_get(&v, 1, &unselect)) return va;
+ if (eina_value_type_get(&unselect) == EINA_VALUE_TYPE_ERROR)
+ eina_value_error_get(&unselect, &err);
+ eina_value_flush(&unselect);
+ if (!err) return va;
+ if (efl_composite_model_index_get(u->prev) == 0xFFFFFFFF) return va;
+
+ eina_value_flush(&va);
+ return _untangle_rollback(u, err);
+}
+
static void
_untangle_free(void *data,
const Eina_Future *dead_future EINA_UNUSED)
diff --git a/src/tests/elementary/efl_ui_test_select_model.c b/src/tests/elementary/efl_ui_test_select_model.c
index 1100b82e0d..acff5d2ca0 100644
--- a/src/tests/elementary/efl_ui_test_select_model.c
+++ b/src/tests/elementary/efl_ui_test_select_model.c
@@ -1199,6 +1199,74 @@ EFL_START_TEST(efl_test_select_model_failed_unselect_rolls_back_last)
}
EFL_END_TEST
+static Eina_Future *
+_refuse_unselect(Eo *obj, void *pd EINA_UNUSED, const char *property, Eina_Value *value)
+{
+ Eina_Bool flag = EINA_TRUE;
+
+ if (eina_streq(property, "selected") &&
+ (eina_value_type_get(value) == EINA_VALUE_TYPE_BOOL) &&
+ eina_value_bool_get(value, &flag) && !flag)
+ return efl_loop_future_rejected(obj, EINVAL);
+ return efl_model_property_set(efl_super(obj, EFL_OBJECT_OVERRIDE_CLASS), property, value);
+}
+
+// Single mode: a select whose unselect of the row selected before fails is rolled back, as
+// one cancelled while it waits for that unselect is. The unselect runs next to the commit of
+// the new row, and its failure used to be dropped with its result: both rows stayed selected.
+EFL_START_TEST(efl_test_select_model_refused_unselect_rolls_back)
+{
+ EFL_OPS_DEFINE(refuse, EFL_OBJECT_OP_FUNC(efl_model_property_set, _refuse_unselect));
+ Efl_Model *base_model, *model;
+ Eo *rows[3] = { NULL, NULL, NULL };
+ Eina_Value select = eina_value_bool_init(EINA_TRUE);
+ unsigned int i;
+
+ base_model = efl_add_ref(EFL_GENERIC_MODEL_CLASS, efl_main_loop_get());
+ for (i = 0; i < 3; ++i)
+ {
+ ck_assert(!!efl_model_child_add(base_model));
+ }
+ model = efl_add_ref(EFL_UI_SELECT_MODEL_CLASS, efl_main_loop_get(),
+ efl_ui_view_model_set(efl_added, base_model));
+ efl_ui_multi_selectable_select_mode_set(model, EFL_UI_SELECT_MODE_SINGLE);
+ eina_future_then(efl_model_children_slice_get(model, 0, 3), _four_rows_then, rows, NULL);
+ for (i = 0; (i < 12) && !rows[2]; i++)
+ {
+ ecore_main_loop_iterate();
+ }
+ ck_assert(!!rows[2]);
+
+ efl_ui_multi_selectable_ndx_range_select(model, 2, 2);
+ for (i = 0; i < 12; i++)
+ {
+ ecore_main_loop_iterate();
+ }
+ ck_assert_ptr_eq(efl_ui_selectable_last_selected_get(model), rows[2]);
+
+ ck_assert(efl_object_override(rows[2], &refuse));
+ efl_model_property_set(rows[0], "self.selected", &select);
+ for (i = 0; i < 16; i++)
+ {
+ ecore_main_loop_iterate();
+ }
+
+ ck_assert_int_eq(_state_get(rows[0], "selected"), EINA_FALSE);
+ ck_assert_int_eq(_state_get(rows[2], "selected"), EINA_TRUE);
+ ck_assert_ptr_eq(efl_ui_selectable_last_selected_get(model), rows[2]);
+ ck_assert_int_eq(_selected_count(model, &i), 1);
+ ck_assert_int_eq(i, 2);
+
+ ck_assert(efl_object_override(rows[2], NULL));
+ for (i = 0; i < 3; i++)
+ {
+ efl_unref(rows[i]);
+ }
+ efl_unref(model);
+ efl_unref(base_model);
+}
+EFL_END_TEST
+
static Eina_Value
_rows_then(void *data, const Eina_Value v, const Eina_Future *dead EINA_UNUSED)
{
@@ -1530,6 +1598,7 @@ efl_ui_test_select_model(TCase *tc)
tcase_add_test(tc, efl_test_select_model_repick_after_clear_rows_not_held);
tcase_add_test(tc, efl_test_select_model_pick_follows_removed_row);
tcase_add_test(tc, efl_test_select_model_failed_unselect_rolls_back_last);
+ tcase_add_test(tc, efl_test_select_model_refused_unselect_rolls_back);
tcase_add_test(tc, efl_test_select_model_gone_row_is_not_selected);
tcase_add_test(tc, efl_test_select_model_single_selects_in_one_turn);
tcase_add_test(tc, efl_test_select_model_single_to_none_unselects_all);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.