jackdanielz pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=976a33e36a6309133483d851495a5ed6d914628a
commit 976a33e36a6309133483d851495a5ed6d914628a Author: Daniel Zaoui <[email protected]> Date: Mon Nov 26 10:32:31 2018 +0200 FlipSelector: fix items creation when range is used In the case step is 0, the application will enter in an infinite loop where the max will never be reached. To fix this, step is set to 1 if 0 is given by the user. Moreover, step is forced to positive. According to the given min and max values, the step will be negative or positive. In this way, we are sure to be inside the correct range. --- src/lib/elementary/elm_flipselector.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/elementary/elm_flipselector.c b/src/lib/elementary/elm_flipselector.c index 54b6957e9c..4aeaf9b125 100644 --- a/src/lib/elementary/elm_flipselector.c +++ b/src/lib/elementary/elm_flipselector.c @@ -456,14 +456,18 @@ static void _items_add(Evas_Object *obj) { double d; + Eina_Bool reverse; char buf[16]; ELM_FLIPSELECTOR_DATA_GET(obj, sd); + reverse = (sd->val_min > sd->val_max); _clear_items(obj); - for (d = sd->val_min; d < sd->val_max; d = d + sd->step) + for (d = sd->val_min; d < sd->val_max;) { snprintf(buf, sizeof(buf), "%.2f", d); elm_flipselector_item_append(obj, buf, NULL, NULL); + if (reverse) d = d - sd->step; + else d = d + sd->step; } snprintf(buf, sizeof(buf), "%.2f", sd->val_max); elm_flipselector_item_append(obj, buf, NULL, NULL); @@ -472,7 +476,6 @@ _items_add(Evas_Object *obj) EOLIAN static void _elm_flipselector_efl_ui_range_range_min_max_set(Eo *obj, Elm_Flipselector_Data *sd, double min, double max) { - if (min > max) return; if ((sd->val_min == min) && (sd->val_max == max)) return; sd->val_min = min; @@ -493,6 +496,9 @@ _elm_flipselector_efl_ui_range_range_step_set(Eo *obj EINA_UNUSED, Elm_Flipselec { if (sd->step == step) return; + if (step == 0.0) step = 1.0; + else if (step < 0.0) step *= -1; + sd->step = step; _items_add(obj); } --
