1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-06 17:25:19 +00:00

Range: Fix cases where max was set to or below min value

It will now raise an error whenever this happens so that we can fix
these situations. `max == min` is not allowed as it could lead to
divisions by zero in ratios, and `max < min` doesn't make much sense.

Fixes #33907.
This commit is contained in:
Rémi Verschelde
2019-11-26 10:25:41 +01:00
parent 55f86e9b7b
commit bfd5e09879
5 changed files with 7 additions and 9 deletions

View File

@@ -100,6 +100,7 @@ void Range::set_value(double p_val) {
shared->emit_value_changed();
}
void Range::set_min(double p_min) {
ERR_FAIL_COND_MSG(p_min >= shared->max, "Range cannot have min value higher or equal to its max value.");
shared->min = p_min;
set_value(shared->val);
@@ -109,6 +110,7 @@ void Range::set_min(double p_min) {
update_configuration_warning();
}
void Range::set_max(double p_max) {
ERR_FAIL_COND_MSG(p_max <= shared->min, "Range cannot have max value lower or equal to its min value.");
shared->max = p_max;
set_value(shared->val);