-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Cannot get ratio when minimum and maximum value are equal" #43179
Comments
At some point, this behaviour would yield dividing by zero. First of all, if the min and max are zero and the value is also zero, where does the thumb of the slider reside? What should the percentage show if At this point, does not sound like a bug. If anything, throw a configuration error. |
Just like @nathanfranke said, this doesn't look like a bug; the slider is not meant to be used with non proper max and min values, so it's kind of creating a problem where there isn't one. |
@ev1lbl0w these are proper values. I see a work-round for setting max value to something more than min val + setting |
@me2beats That's a fair argument, but before changes will be made we must agree on exact behaviour, including but not necessarily limited to these questions:
|
According to the above links, when |
Btw, this error does not seem to interfere with starting the game. But not sure that ignoring it won't cause the game to crash someday.
|
Understandable, I was actually referring to percent_visible in ProgressBar which extends Range. |
This error was added in #33583.
This is because most error macros are not harmful, those are just In my opinion, the class implementation should just handle those cases gracefully, and return either Or even |
If this is going to take a while to get addressed, can we at least get the error log in the console to link to the line of code that is generating the error? |
An error message is also no longer printed. This matches the behavior found in most UI frameworks where having equal minimum and maximum values is considered acceptable. This closes godotengine#43179.
You can use a divide and conquer approach for now. Try removing nodes inheriting from Range from your scene tree until the error no longer pops up. Also, if you can recompile the editor, you could change this line in ERR_FAIL_COND_V_MSG(Math::is_equal_approx(get_max(), get_min()), 0.0, "Cannot get ratio when minimum and maximum value are equal."); To: ERR_FAIL_COND_V_MSG(Math::is_equal_approx(get_max(), get_min()), 0.0, vformat("Cannot get ratio of %s when minimum (%f) and maximum (%f) value are equal.", get_name(), get_min(), get_max())); |
An error message is also no longer printed. This matches the behavior found in most UI frameworks where having equal minimum and maximum values is considered acceptable. This closes godotengine#43179. (cherry picked from commit 44204ec)
An error message is also no longer printed. This matches the behavior found in most UI frameworks where having equal minimum and maximum values is considered acceptable. This closes godotengine#43179.
Godot version:
3.2.3 stable
OS/device including version:
Windows
Issue description:
When I set a slider min and max val to 0, it throws the following error:
Q: Why do I need this at all?
A: I'm creating an Undo slider like in ZBrush.
When a project starts, there's nothing to undo, so the undo slider max val is 0 (and min val is always 0)
Steps to reproduce:
set a slider (HSlider or VSlider) min and max val to an equal value, say to 0, in Ispector or with a script.
Minimal reproduction project:
The text was updated successfully, but these errors were encountered: