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 a69f058019c7e669ada70c3827c2e71fbfad1a95
Author: Cedric BAIL <[email protected]>
AuthorDate: Tue Nov 10 18:13:03 2026 -0600
elementary: select_model: fallback takes over after a direct unselect
The fallback was only looked at once the previous row was already
forgotten, and the check it made began with "something is selected", so
it never fired. The commit path also handed it the parent's data instead
of the row's, which has no parent. It now takes the parent's data and
the row that gave up the selection, and is skipped when that row is the
fallback itself.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/elementary/efl_ui_select_model.c | 18 ++++---
src/tests/elementary/efl_ui_test_select_model.c | 66 +++++++++++++++++++++++++
2 files changed, 76 insertions(+), 8 deletions(-)
diff --git a/src/lib/elementary/efl_ui_select_model.c b/src/lib/elementary/efl_ui_select_model.c
index 1d69c9a232..2112239f33 100644
--- a/src/lib/elementary/efl_ui_select_model.c
+++ b/src/lib/elementary/efl_ui_select_model.c
@@ -85,19 +85,21 @@ _efl_ui_select_model_efl_object_invalidate(Eo *obj,
efl_invalidate(efl_super(obj, EFL_UI_SELECT_MODEL_CLASS));
}
+// @child was the selected row and is not anymore: the fallback takes its place, unless
+// the fallback is @child, which is the one asked to give up the selection.
static void
-_efl_ui_select_model_fallback(Efl_Ui_Select_Model_Data *pd)
+_efl_ui_select_model_fallback(Efl_Ui_Select_Model_Data *parent_pd, Eo *child)
{
Eina_Value selected;
- if (!pd->parent) return;
- if (!pd->parent->last_model) return;
- if (!pd->parent->fallback_model) return;
+ if (!parent_pd) return;
+ if (!parent_pd->fallback_model) return;
+ if (parent_pd->fallback_model == child) return;
// I think it only make sense to trigger the fallback on single mode
- if (pd->parent->selection != EFL_UI_SELECT_MODE_SINGLE) return;
+ if (parent_pd->selection != EFL_UI_SELECT_MODE_SINGLE) return;
selected = eina_value_bool_init(EINA_TRUE);
- efl_model_property_set(pd->parent->fallback_model, "self.selected", &selected);
+ efl_model_property_set(parent_pd->fallback_model, "self.selected", &selected);
eina_value_flush(&selected);
}
@@ -159,7 +161,7 @@ _commit_change(Eo *child, void *data EINA_UNUSED, const Eina_Value v)
_efl_ui_select_model_apply_last_model(parent, pd, NULL);
// Just in case we need to refill the fallback
- _efl_ui_select_model_fallback(pd);
+ _efl_ui_select_model_fallback(pd, child);
}
efl_event_callback_call(child, EFL_UI_SELECT_MODEL_EVENT_UNSELECTED, child);
}
@@ -479,7 +481,7 @@ _efl_ui_select_model_efl_model_property_set(Eo *obj,
{
_efl_ui_select_model_apply_last_model(efl_parent_get(obj), pd->parent, NULL);
- _efl_ui_select_model_fallback(pd);
+ _efl_ui_select_model_fallback(pd->parent, obj);
}
}
else if (pd->parent->last_model)
diff --git a/src/tests/elementary/efl_ui_test_select_model.c b/src/tests/elementary/efl_ui_test_select_model.c
index 55cd35ab10..4382a5fb8e 100644
--- a/src/tests/elementary/efl_ui_test_select_model.c
+++ b/src/tests/elementary/efl_ui_test_select_model.c
@@ -837,6 +837,71 @@ EFL_START_TEST(efl_test_select_model_multi_to_single_pick_a_selected_row)
}
EFL_END_TEST
+static Eina_Value
+_rows_then(void *data, const Eina_Value v, const Eina_Future *dead EINA_UNUSED)
+{
+ Eo **rows = data;
+ unsigned int i, len;
+ Eo *c;
+
+ EINA_VALUE_ARRAY_FOREACH(&v, len, i, c)
+ {
+ rows[i] = efl_ref(c);
+ }
+ return v;
+}
+
+// The fallback takes over when the selected row is unselected directly.
+EFL_START_TEST(efl_test_select_model_fallback_after_direct_unselect)
+{
+ Efl_Model *base_model, *model;
+ Eo *rows[4] = { NULL, NULL, NULL, NULL };
+ Eina_Value unselect = eina_value_bool_init(EINA_FALSE);
+ unsigned int i, 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);
+ eina_future_then(efl_model_children_slice_get(model, 0, 4), _rows_then, rows, NULL);
+ for (i = 0; (i < 12) && !rows[3]; i++)
+ {
+ ecore_main_loop_iterate();
+ }
+ ck_assert(!!rows[3]);
+
+ efl_ui_selectable_fallback_selection_set(model, rows[0]);
+ efl_ui_multi_selectable_ndx_range_select(model, 3, 3);
+ for (i = 0; i < 12; i++)
+ {
+ ecore_main_loop_iterate();
+ }
+ ck_assert_int_eq(_selected_count(model, &first), 1);
+ ck_assert_int_eq(first, 3);
+
+ eina_future_then(efl_model_property_set(rows[3], "self.selected", &unselect),
+ _state_ignore, NULL, NULL);
+ for (i = 0; i < 16; i++)
+ {
+ ecore_main_loop_iterate();
+ }
+ ck_assert_int_eq(_selected_count(model, &first), 1);
+ ck_assert_int_eq(first, 0);
+ ck_assert_ptr_eq(efl_ui_selectable_last_selected_get(model), rows[0]);
+
+ for (i = 0; i < 4; i++)
+ {
+ efl_unref(rows[i]);
+ }
+ efl_unref(model);
+ efl_unref(base_model);
+}
+EFL_END_TEST
+
void
efl_ui_test_select_model(TCase *tc)
{
@@ -854,4 +919,5 @@ efl_ui_test_select_model(TCase *tc)
tcase_add_test(tc, efl_test_select_model_single_later_direct_select_wins);
tcase_add_test(tc, efl_test_select_model_noop_select_keeps_index_select);
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);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.