-
Notifications
You must be signed in to change notification settings - Fork 381
fix: settings window crash after changing tile dimensions #2796
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
base: main
Are you sure you want to change the base?
Conversation
…sions Fixes #2795 This fix ensures that when updating value ranges within Sliders and LabeledSliders: - If the new minimum is greater than the current maximum, we set the maximum first to avoid the validation error - If the new maximum is less than the current minimum, we set the minimum first - Otherwise, we can safely set them in the original order This prevents the intermediate state where minimum temporarily exceeds maximum, which was causing the crash when opening the settings window after changing tile dimensions.
| else if (max < Minimum) | ||
| { | ||
| Minimum = min; | ||
| Maximum = max; | ||
| } | ||
| else | ||
| { | ||
| // Safe to set in either order | ||
| Minimum = min; | ||
| Maximum = max; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The body of these are the exact same? Just combine them (by removing the else if)
| public void SetRange(double min, double max) => (Minimum, Maximum) = (min, max); | ||
| public void SetRange(double min, double max) | ||
| { | ||
| if (min > Maximum) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this if there should be a safety check ensuring that min is actually the minimum, and max is actually the maximum.
e.g.
var actualMin = Math.Min(min, max);
var actualMax = Math.Max(min, max);Then use actualMin and actualMax throughout the rest of the method.
| { | ||
| _minimumValue = min; | ||
| _maximumValue = max; | ||
| if (min > Maximum) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both comments from LabeledSlider apply here
(tested: working as intended!) Signed-off-by: Arufonsu <17498701+Arufonsu@users.noreply.github.com>
Fixes #2795
This fix ensures that when updating value ranges within Sliders and LabeledSliders:
This prevents the intermediate state where minimum temporarily exceeds maximum, which was causing the crash when opening the settings window after changing tile dimensions.
Note: Tested by decreasing dimensions from 32x32 to 16x16, leading to no more crashes at settings windows
