From 8cde76ea7159c632713ab285cb35f46db4ad64a9 Mon Sep 17 00:00:00 2001
From: Aru <17498701+Arufonsu@users.noreply.github.com>
Date: Tue, 6 Jan 2026 20:58:46 -0300
Subject: [PATCH] fix: crash when opening the settings window after changing
tile dimensions
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.
---
.../Gwen/Control/LabeledSlider.cs | 20 ++++++++++++++++++-
.../Gwen/Control/Slider.cs | 18 +++++++++++++++--
2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/Intersect.Client.Framework/Gwen/Control/LabeledSlider.cs b/Intersect.Client.Framework/Gwen/Control/LabeledSlider.cs
index 20d4b670ea..56af960e26 100644
--- a/Intersect.Client.Framework/Gwen/Control/LabeledSlider.cs
+++ b/Intersect.Client.Framework/Gwen/Control/LabeledSlider.cs
@@ -378,7 +378,25 @@ protected override void OnChildSizeChanged(Base child, Point oldChildSize, Point
SizeToChildren(resizeX: AutoSizeToContentWidthOnChildResize, resizeY: AutoSizeToContentHeightOnChildResize);
}
- public void SetRange(double min, double max) => (Minimum, Maximum) = (min, max);
+ public void SetRange(double min, double max)
+ {
+ if (min > Maximum)
+ {
+ Maximum = max;
+ Minimum = min;
+ }
+ else if (max < Minimum)
+ {
+ Minimum = min;
+ Maximum = max;
+ }
+ else
+ {
+ // Safe to set in either order
+ Minimum = min;
+ Maximum = max;
+ }
+ }
public bool AutoSizeToContents
{
diff --git a/Intersect.Client.Framework/Gwen/Control/Slider.cs b/Intersect.Client.Framework/Gwen/Control/Slider.cs
index f47fb7d4d4..4a7bbb8bc8 100644
--- a/Intersect.Client.Framework/Gwen/Control/Slider.cs
+++ b/Intersect.Client.Framework/Gwen/Control/Slider.cs
@@ -458,8 +458,22 @@ protected virtual void SetValueInternal(double newInternalValue, bool forceUpdat
/// Maximum value.
public void SetRange(double min, double max)
{
- _minimumValue = min;
- _maximumValue = max;
+ if (min > Maximum)
+ {
+ _maximumValue = max;
+ _minimumValue = min;
+ }
+ else if (max < Minimum)
+ {
+ _minimumValue = min;
+ _maximumValue = max;
+ }
+ else
+ {
+ // Safe to set in either order
+ _minimumValue = min;
+ _maximumValue = max;
+ }
}
///