Skip to content

Conversation

@Arufonsu
Copy link
Contributor

@Arufonsu Arufonsu commented Jan 7, 2026

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.

Note: Tested by decreasing dimensions from 32x32 to 16x16, leading to no more crashes at settings windows
{860FFCF6-ECC1-4B10-8EBF-6DAADC636395}

…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.
@Arufonsu Arufonsu requested review from a team January 7, 2026 00:03
@Arufonsu Arufonsu added the bug Something isn't working label Jan 7, 2026
Comment on lines 388 to 398
else if (max < Minimum)
{
Minimum = min;
Maximum = max;
}
else
{
// Safe to set in either order
Minimum = min;
Maximum = max;
}
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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>
@Arufonsu Arufonsu requested a review from pandinocoder February 1, 2026 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Tile change > Options not working

3 participants