You've already forked godot
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user