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 e576760a87120338421a16f5d7c41dd5929eaed3
Author: Cedric BAIL <[email protected]>
AuthorDate: Tue Nov 10 18:13:31 2026 -0600
elementary: select_model: none clears despite no manual deselection
With allow_manual_deselection false, single -> none -> single kept the
old row when the mode came back before the queued unselects ran: they
then met single mode and the refusal meant for a person giving up the
selection.
Going to none is the mode taking the selection away, not a manual
deselection, so those unselects are not refused and nothing (the
fallback included) takes the place of what they unselect. Back in single
mode, nothing is selected until a row is picked.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/elementary/efl_ui_select_model.c | 26 +++++++++++++++-
src/tests/elementary/efl_ui_test_select_model.c | 40 +++++++++++++++++++++++++
2 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/src/lib/elementary/efl_ui_select_model.c b/src/lib/elementary/efl_ui_select_model.c
index a4a9b216e0..8786211654 100644
--- a/src/lib/elementary/efl_ui_select_model.c
+++ b/src/lib/elementary/efl_ui_select_model.c
@@ -29,11 +29,15 @@ struct _Efl_Ui_Select_Model_Data
unsigned int select_seq;
Eina_Bool allow_manual_deselection : 1;
+ // Set while the unselects that going to none asks for are applied: they are not a manual
+ // deselection, and nothing takes the place of what they unselect
+ Eina_Bool clearing : 1;
};
static void _unselect_range(Eo *obj, unsigned int a, unsigned int b,
Eina_Value (*then)(Eo *o, void *data, const Eina_Value v));
static Eina_Value _children_unselect_keep_picked_then(Eo *o, void *data, const Eina_Value v);
+static Eina_Value _children_unselect_clear_then(Eo *o, void *data, const Eina_Value v);
static void
_efl_ui_select_model_apply_last_model(Eo *obj, Efl_Ui_Select_Model_Data *pd, Eo *last_model)
@@ -95,6 +99,7 @@ _efl_ui_select_model_fallback(Efl_Ui_Select_Model_Data *parent_pd, Eo *child)
if (!parent_pd) return;
if (!parent_pd->fallback_model) return;
if (parent_pd->fallback_model == child) return;
+ if (parent_pd->clearing) return;
// I think it only make sense to trigger the fallback on single mode
if (parent_pd->selection != EFL_UI_SELECT_MODE_SINGLE) return;
@@ -509,6 +514,7 @@ _efl_ui_select_model_efl_model_property_set(Eo *obj,
if (!newflag &&
(pd->parent->selection == EFL_UI_SELECT_MODE_SINGLE) &&
(!pd->parent->allow_manual_deselection) &&
+ (!pd->parent->clearing) &&
(!pd->parent->fallback_model) &&
(pd->parent->last_model == obj))
return efl_loop_future_resolved(obj, eina_value_bool_init(EINA_TRUE));
@@ -725,7 +731,11 @@ _efl_ui_select_model_efl_ui_multi_selectable_select_mode_set(Eo *obj,
case EFL_UI_SELECT_MODE_NONE:
// Every row, from single mode too: one selected but not known as the last one (kept
// on leaving multiple selection, before it is fetched) would come back in multi
- efl_ui_multi_selectable_all_unselect(obj);
+ {
+ unsigned int count = efl_model_children_count_get(obj);
+
+ if (count) _unselect_range(obj, 0, count - 1, _children_unselect_clear_then);
+ }
break;
case EFL_UI_SELECT_MODE_MULTI:
break;
@@ -845,6 +855,20 @@ _children_unselect_keep_picked_then(Eo *o, void *data EINA_UNUSED, const Eina_Va
return v;
}
+// What going to none unselects, which allow_manual_deselection does not refuse
+static Eina_Value
+_children_unselect_clear_then(Eo *o, void *data, const Eina_Value v)
+{
+ Efl_Ui_Select_Model_Data *pd = efl_data_scope_get(o, EFL_UI_SELECT_MODEL_CLASS);
+ Eina_Value r;
+
+ pd->clearing = EINA_TRUE;
+ r = _children_unselect_then(o, data, v);
+ pd->clearing = EINA_FALSE;
+
+ return r;
+}
+
#define BATCH_MAX 100
static void
diff --git a/src/tests/elementary/efl_ui_test_select_model.c b/src/tests/elementary/efl_ui_test_select_model.c
index d35fa2afaf..d10bfacc6b 100644
--- a/src/tests/elementary/efl_ui_test_select_model.c
+++ b/src/tests/elementary/efl_ui_test_select_model.c
@@ -970,6 +970,45 @@ EFL_START_TEST(efl_test_select_model_failed_unselect_rolls_back_last)
}
EFL_END_TEST
+// Going to none unselects every row, whatever allow_manual_deselection says: that is not a
+// person giving up the selection but the mode taking it away. Back in single mode nothing
+// is selected, whether the mode came back at once or after the unselects ran.
+EFL_START_TEST(efl_test_select_model_none_clears_without_manual_deselection)
+{
+ Efl_Model *base_model, *model;
+ unsigned int i, round, first = 99;
+
+ base_model = efl_add_ref(EFL_GENERIC_MODEL_CLASS, efl_main_loop_get());
+ for (i = 0; i < 6; ++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_selectable_allow_manual_deselection_set(model, EINA_FALSE);
+
+ for (round = 0; round < 2; round++)
+ {
+ efl_ui_multi_selectable_ndx_range_select(model, 1, 1);
+ for (i = 0; i < 12; i++) ecore_main_loop_iterate();
+ ck_assert_int_eq(_selected_count(model, &first), 1);
+ ck_assert_int_eq(first, 1);
+
+ efl_ui_multi_selectable_select_mode_set(model, EFL_UI_SELECT_MODE_NONE);
+ // (round 0: back to single in the same turn, round 1: once the unselects ran)
+ if (round) for (i = 0; i < 12; i++) ecore_main_loop_iterate();
+ efl_ui_multi_selectable_select_mode_set(model, EFL_UI_SELECT_MODE_SINGLE);
+ for (i = 0; i < 12; i++) ecore_main_loop_iterate();
+ ck_assert_int_eq(_selected_count(model, NULL), 0);
+ ck_assert_ptr_eq(efl_ui_selectable_last_selected_get(model), NULL);
+ }
+
+ efl_unref(model);
+ efl_unref(base_model);
+}
+EFL_END_TEST
+
void
efl_ui_test_select_model(TCase *tc)
{
@@ -989,4 +1028,5 @@ efl_ui_test_select_model(TCase *tc)
tcase_add_test(tc, efl_test_select_model_multi_to_single_pick_a_selected_row);
tcase_add_test(tc, efl_test_select_model_fallback_after_direct_unselect);
tcase_add_test(tc, efl_test_select_model_failed_unselect_rolls_back_last);
+ tcase_add_test(tc, efl_test_select_model_none_clears_without_manual_deselection);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.