Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

PopupRenderer: check for isDisposed in OnElementPropertyChanged before taking action. Fixes https://github.com/xamarin/XamarinCommunityToolkit/issues/1947 #1968

Merged
merged 1 commit into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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