Skip to content

Commit

Permalink
Debugger: Fixed crash when emptying hex textboxes in some scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
SourMesen committed May 11, 2024
1 parent bb034e6 commit cc58fe4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions UI/Controls/MesenNumericTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ private void UpdateValueFromText()
{
if(string.IsNullOrWhiteSpace(Text)) {
long? min = GetMin();
if(min != null) {
SetNewValue(Math.Min(0, min.Value));
if(min != null && min.Value > 0) {
SetNewValue((IComparable)Convert.ChangeType(min.Value, Value.GetType()));
} else {
SetNewValue(0);
SetNewValue((IComparable)Convert.ChangeType(0, Value.GetType()));
}
}

Expand Down Expand Up @@ -228,7 +228,7 @@ private void SetNewValue(IComparable val)
} else if(min != null && val.CompareTo(Convert.ChangeType(min, val.GetType())) < 0) {
val = (IComparable)Convert.ChangeType(min, val.GetType());
} else if(min == null && val.CompareTo(Convert.ChangeType(0, val.GetType())) < 0) {
val = 0;
val = (IComparable)Convert.ChangeType(0, val.GetType());
}
if(!object.Equals(Value, val)) {
Value = val;
Expand Down

0 comments on commit cc58fe4

Please sign in to comment.