Skip to content

Commit ed04d39

Browse files
Illustar0Arlodotexe
authored andcommitted
fix: replace null suppression with null checks in DragWidth
Replaced the unsafe null-forgiving operator (!) with explicit null checks to prevent potential runtime exceptions when container or thumb is null. Signed-off-by: Illustar0 <me@illustar0.com>
1 parent 618d89d commit ed04d39

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

components/RangeSelector/src/RangeSelector.Input.Drag.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,12 @@ private void Thumb_DragCompleted(object sender, DragCompletedEventArgs e)
7777

7878
private double DragWidth()
7979
{
80-
return new UVCoord(_containerCanvas!.ActualWidth, _containerCanvas.ActualHeight, Orientation).U
81-
- new UVCoord(_maxThumb!.Width, _maxThumb.Height, Orientation).U;
80+
if (_containerCanvas == null || _maxThumb == null)
81+
{
82+
return 0;
83+
}
84+
return new UVCoord(_containerCanvas.ActualWidth, _containerCanvas.ActualHeight, Orientation).U
85+
- new UVCoord(_maxThumb.Width, _maxThumb.Height, Orientation).U;
8286
}
8387

8488
private double DragThumb(Thumb? thumb, double min, double max, double nextPos)

0 commit comments

Comments
 (0)