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 fbece8d35d7aba201d9aabefde114031c66c84cd
Author: Cedric BAIL <[email protected]>
AuthorDate: Mon Nov 9 01:35:08 2026 -0600
elementary: Select_Model single mode lets the later selection win
A selection by index (index_range_select, "child.selected") first
fetches its row, a turn later. A row selected directly meanwhile, by a
click, became last_model at once; the index selection then arrived,
unselected the clicked row and took its place. The earlier request won
over the later one, and a click made while an application's selection
was on its way was lost without any trace.
Selections are now counted when asked for. In single mode a selection
by index that finds a newer one asked for while its row was fetched is
dropped: the later one is the selection. Multiple selection keeps every
request.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/elementary/efl_ui_select_model.c | 15 ++++++-
src/tests/elementary/efl_ui_test_select_model.c | 52 +++++++++++++++++++++++++
2 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/src/lib/elementary/efl_ui_select_model.c b/src/lib/elementary/efl_ui_select_model.c
index 76588eace8..543c498cbb 100644
--- a/src/lib/elementary/efl_ui_select_model.c
+++ b/src/lib/elementary/efl_ui_select_model.c
@@ -24,6 +24,9 @@ struct _Efl_Ui_Select_Model_Data
Efl_Ui_Select_Model *last_model;
Efl_Ui_Select_Mode selection;
+ // Counts the selections asked for: one by index fetches its row first, and in single mode
+ // a selection asked for meanwhile is the later one
+ unsigned int select_seq;
Eina_Bool allow_manual_deselection : 1;
};
@@ -249,13 +252,19 @@ _unselect_child(Efl_Model *child)
}
static Eina_Value
-_select_slice_then(Eo *obj EINA_UNUSED,
- void *data EINA_UNUSED,
+_select_slice_then(Eo *obj,
+ void *data,
const Eina_Value v)
{
+ Efl_Ui_Select_Model_Data *pd = efl_data_scope_get(obj, EFL_UI_SELECT_MODEL_CLASS);
+ unsigned int seq = (unsigned int) (uintptr_t) data;
Efl_Model *child = NULL;
Eina_Future *r;
+ // Single mode: a selection asked for after this one, while its row was fetched, wins
+ if ((pd->selection == EFL_UI_SELECT_MODE_SINGLE) && (pd->select_seq != seq))
+ return v;
+
child = _select_child_get(&v, 0);
if (!child) goto on_error;
@@ -392,6 +401,7 @@ _efl_ui_select_model_efl_model_property_set(Eo *obj,
return efl_future_then(efl_ref(obj), efl_model_children_slice_get(obj, l, 1),
.success = _select_slice_then,
.success_type = EINA_VALUE_TYPE_ARRAY,
+ .data = "" *) (uintptr_t) ++pd->select_seq,
.free = _clear_child);
}
@@ -417,6 +427,7 @@ _efl_ui_select_model_efl_model_property_set(Eo *obj,
// row, and those unselects arrive once the mode is none
if ((pd->parent->selection == EFL_UI_SELECT_MODE_NONE) && newflag)
return efl_loop_future_rejected(obj, EFL_MODEL_ERROR_INCORRECT_VALUE);
+ if (newflag) pd->parent->select_seq++;
// Nothing changed
if (newflag == prevflag)
diff --git a/src/tests/elementary/efl_ui_test_select_model.c b/src/tests/elementary/efl_ui_test_select_model.c
index b1d9688fe5..12cdfb65f7 100644
--- a/src/tests/elementary/efl_ui_test_select_model.c
+++ b/src/tests/elementary/efl_ui_test_select_model.c
@@ -678,6 +678,57 @@ EFL_START_TEST(efl_test_select_model_manual_deselection)
}
EFL_END_TEST
+static Eina_Value
+_state_ignore(void *data EINA_UNUSED, const Eina_Value v,
+ const Eina_Future *dead_future EINA_UNUSED)
+{
+ return v;
+}
+
+// Single mode: a row selected directly (a click) after a selection by index was asked for,
+// before that one fetched its row, is the later one and wins.
+EFL_START_TEST(efl_test_select_model_single_later_direct_select_wins)
+{
+ Efl_Model *base_model, *model;
+ Eo *kids[2] = { NULL, NULL };
+ Eina_Value select = eina_value_bool_init(EINA_TRUE);
+ unsigned int i, first = 99;
+
+ base_model = efl_add_ref(EFL_GENERIC_MODEL_CLASS, efl_main_loop_get());
+ for (i = 0; i < 10; ++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);
+ efl_ui_multi_selectable_ndx_range_select(model, 2, 2);
+ eina_future_then(efl_model_children_slice_get(model, 8, 1), _gone_then, kids, NULL);
+ for (i = 0; i < 12; i++)
+ {
+ ecore_main_loop_iterate();
+ }
+ ck_assert(!!kids[0]);
+ ck_assert_int_eq(_selected_count(model, &first), 1);
+ ck_assert_int_eq(first, 2);
+
+ efl_ui_multi_selectable_ndx_range_select(model, 5, 5);
+ eina_future_then(efl_model_property_set(kids[0], "self.selected", &select),
+ _state_ignore, NULL, NULL);
+ for (i = 0; i < 12; i++)
+ {
+ ecore_main_loop_iterate();
+ }
+ ck_assert_int_eq(_selected_count(model, &first), 1);
+ ck_assert_int_eq(first, 8);
+ ck_assert_ptr_eq(efl_ui_selectable_last_selected_get(model), kids[0]);
+
+ efl_unref(kids[0]);
+ efl_unref(model);
+ efl_unref(base_model);
+}
+EFL_END_TEST
+
void
efl_ui_test_select_model(TCase *tc)
{
@@ -692,4 +743,5 @@ efl_ui_test_select_model(TCase *tc)
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);
tcase_add_test(tc, efl_test_select_model_manual_deselection);
+ tcase_add_test(tc, efl_test_select_model_single_later_direct_select_wins);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.