Skip to content

Commit

Permalink
PopupRenderer: check for isDisposed in OnElementPropertyChanged befor…
Browse files Browse the repository at this point in the history
…e taking action. Fixes xamarin#1947
  • Loading branch information
mfeingol committed May 4, 2023
1 parent ecbc831 commit 8329323
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public override void Show()

protected virtual void OnElementPropertyChanged(object? sender, PropertyChangedEventArgs args)
{
if (Element is BasePopup basePopup)
if (Element is BasePopup basePopup && !isDisposed)
{
if (args.PropertyName == BasePopup.VerticalOptionsProperty.PropertyName
|| args.PropertyName == BasePopup.HorizontalOptionsProperty.PropertyName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,15 @@ protected virtual void OnElementChanged(ElementChangedEventArgs<BasePopup?> e)

protected virtual void OnElementPropertyChanged(object? sender, PropertyChangedEventArgs args)
{
if (args.PropertyName == BasePopup.VerticalOptionsProperty.PropertyName ||
args.PropertyName == BasePopup.HorizontalOptionsProperty.PropertyName ||
args.PropertyName == BasePopup.SizeProperty.PropertyName ||
args.PropertyName == BasePopup.ColorProperty.PropertyName)
if (Element is BasePopup basePopup && !isDisposed)
{
ConfigureControl();
if (args.PropertyName == BasePopup.VerticalOptionsProperty.PropertyName ||
args.PropertyName == BasePopup.HorizontalOptionsProperty.PropertyName ||
args.PropertyName == BasePopup.SizeProperty.PropertyName ||
args.PropertyName == BasePopup.ColorProperty.PropertyName)
{
ConfigureControl();
}
}

ElementPropertyChanged?.Invoke(this, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,21 @@ protected virtual void OnElementChanged(ElementChangedEventArgs<BasePopup?> e)

protected virtual void OnElementPropertyChanged(object? sender, PropertyChangedEventArgs args)
{
if (args.PropertyName == BasePopup.VerticalOptionsProperty.PropertyName ||
args.PropertyName == BasePopup.HorizontalOptionsProperty.PropertyName)
if (Element is BasePopup basePopup && !isDisposed)
{
SetLayout();
}
else if (args.PropertyName == BasePopup.SizeProperty.PropertyName)
{
SetSize();
}
else if (args.PropertyName == BasePopup.ColorProperty.PropertyName)
{
SetBackgroundColor();
if (args.PropertyName == BasePopup.VerticalOptionsProperty.PropertyName ||
args.PropertyName == BasePopup.HorizontalOptionsProperty.PropertyName)
{
SetLayout();
}
else if (args.PropertyName == BasePopup.SizeProperty.PropertyName)
{
SetSize();
}
else if (args.PropertyName == BasePopup.ColorProperty.PropertyName)
{
SetBackgroundColor();
}
}

ElementPropertyChanged?.Invoke(this, args);
Expand Down

0 comments on commit 8329323

Please sign in to comment.