Skip to content

Commit

Permalink
fix: Don't fail on disposed color changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Oct 4, 2024
1 parent 22f8493 commit 1c5621e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/TextBox/TextBoxView.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ internal partial class TextBoxView : EditText, DependencyObject
internal TextBox? Owner => _ownerRef?.Target as TextBox;

private Action? _foregroundChanged;
private bool _isDisposed;

public TextBoxView(TextBox owner)
: base(ContextHelper.Current)
Expand Down Expand Up @@ -313,10 +314,23 @@ private void OnForegroundChanged(Brush oldValue, Brush newValue)

void ApplyColor()
{
if (_isDisposed)
{
// Binding changes may happen after the
// underlying control has been disposed
return;
}

SetTextColor(scb.Color);
SetCursorColor(scb.Color);
}
}
}

protected override void Dispose(bool disposing)
{
_isDisposed = true;
base.Dispose(disposing);
}
}
}

0 comments on commit 1c5621e

Please sign in to comment.