Fix spinner lower bound - #1778
Conversation
|
Hi, thanks for reporting the issue and creating this PR!
The root cause of this bug are the following lines though: rnote/crates/rnote-ui/src/unitentry.rs Lines 156 to 164 in 99fd77f
So a proper fix would be to either calculate the new value before calling Do you want to make these changes yourself? Or do you want me to take over? |
|
Thank you for the response. You're right that it's better to instead use the pre-clamped value and leave configure_spinner alone. Let me post my change in a second... |
|
Sorry, I had a bit of a mix-up with another account. Is this the kind of change you were looking for? |
|
Yes. Could you add the same fix to the DPI section too (directly below)? In theory, the same bug could occur there. |
|
Great catch! Although I do wonder if there should be a comment placed here briefly saying why we are making copies of these floating point numbers before we run configure_spinner. I am not extremely familiar with Rnote's codebase, and I don't have nearly as much Rust experience as y'all, but to me it seems unintuitive that running configure_spinner(), which is meant to set the spinner's properties will clamp values like these and ruin your conversions. Do you think this warrants a comment? |
|
Well, if you feel this warrant comments, feel free to add them (and refer to the github issue number). The crux of the issue is keeping the UI state (displayed in the UI in the gtk4 element where the spinner bounds apply) and the internal state (the value/unit/dpi properties) coherent when updating. So there's some precautions to take here to update things in a coherent manner (all the more so when updating a property updates more than one like that is the case for unit/dpi). The reason the update on the value occurs is probably rnote/crates/rnote-ui/src/unitentry.rs Lines 80 to 85 in 99fd77f So setting the bounds on the unitentry will trigger a change of the NB : there's other issues with this component, like #1773. |
| self.unit.replace(unit); | ||
| } | ||
| } | ||
| "dpi" => { |
There was a problem hiding this comment.
I actually meant this section with "DPI section". We need the same fix here. But I don't think we need to store the DPI (what your latest commit did).
Maybe it would be best to simply calculate the new value altogether before calling the configure function (instead of doing it inline in the function argument)?
|
I hope that's what was intended. Anything else should be done? |
To fix issue #1777
Cm.to.Px.conversion.fix.webm