GnuTux wrote:
Well, I guess I don't understand the point you are making, in terms of the caller having to sanity check any value returned from SF-ADJUSTMENT. When calling SF-ADJUSTMENT, the precision is specified. The caller should expect the stop point values (and any value in between) to be returned correctly, to the precision specified. I don't see a need for sanity checking of any of those return values, as you seemed to suggest.
I would not say that "the precision is specified", only the
the number of decimal places in the displayed result specified.
While it would be nice if "the precision" were specified, this would introduce some problems with regard to complying with human interface guidelines; one being that the slider box, when dragged, would no longer follow the motion of the mouse pointer. Furthermore, such a change would pose a rather significant change to how GIMP has behaved for nearly two decades.
Though I think this is ultimately a problem with the GTK adjustment widget, I doubt the GTK devs would give much serious consideration to addressing it. Firstly, GIMP is using version 2 of GTK+, whereas GTK3+ was released over four years ago. While I myself think GTK3+ is flawed in many ways and thrilled that GIMP is staying with GTK2+ for now (at least for GIMP 2.10), I would understand any reluctance by the GTK+ devs to addressing a problem that has never been raised as a significant issue, may only affect "outdated" code, may only be properly fixed by redesigning the widget's API, and could arguably be called a design limitation and not a bug.
My guess is that they would claim that the widget behaves as expected (given the constraints of floating point arithmetic) and that you are free to implement your own widget that behaves differently.
GnuTux wrote:
What you've posted is a workaround for a known bug. What if the procedure (SF-ADJUSTMENT) returned a negative value or value greater than 40 or another data type or any number of other anomalies that could possibly be returned. That is what I consider validity checking and it's not necessary here.
My point is that those kinds of checks should be handled inside the procedure (SF-ADJUSTMENT). The coder of SF-ADJUSTMENT should be ensuring the return values are correct. If there is a bug in the procedure that's causing an incorrect value to be returned, it would be discovered by testing, which is how this bug was found. The solution is not to sanity check all possible return values for every function/procedure you call. The solution is to fix the procedure containing the bug. In the interim, a workaround might be necessary.
Currently there is no special treatment of the SF-ADJUSTMENT return values; they are treated just like any other parameter of the PDB_FLOAT type (which is a gdouble). From what I can tell, resolving this in the Script-fu plug-in would be quite messy -- trapping such parameters and then assuming that a certain precision would be sufficient for the coder's purposes.
My recommendation would be to address this issue within the script, because only script writer will know what problems need to be avoided. For example, if the only concern is about testing if
x is "0" then the following should suffice:
(if (zero? (truncate (*
x 1e15)))
If the result is supposed to fall upon precise intervals then the returned value should be rounded to the nearest of those possible intervals. I knew that this was something that had to be done for slider inputs, I just never realized that it applied to spinners as well.
Nonetheless, I shouldn't want to stifle a discussion of potential solutions, I just wouldn't get my hopes up.