Skip to content

Commit

Permalink
Merge pull request #6839 from workgroupengineering/fixes/Issue_6838
Browse files Browse the repository at this point in the history
fixes(DevTools): Double subscribe/unsubscribe INotifyPropertyChanged
  • Loading branch information
maxkatz6 authored and danwalmsley committed Nov 23, 2021
1 parent 33c53c8 commit 25de554
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -435,16 +435,16 @@ public void ApplyParentProperty()

protected void NavigateToProperty(object o, string entityName)
{
if (SelectedEntity is INotifyPropertyChanged inpc1)
var oldSelectedEntity = SelectedEntity;
if (oldSelectedEntity is IAvaloniaObject ao1)
{
inpc1.PropertyChanged -= ControlPropertyChanged;
ao1.PropertyChanged -= ControlPropertyChanged;
}

if (SelectedEntity is AvaloniaObject ao1)
else if (oldSelectedEntity is INotifyPropertyChanged inpc1)
{
ao1.PropertyChanged -= ControlPropertyChanged;
inpc1.PropertyChanged -= ControlPropertyChanged;
}

SelectedEntity = o;
SelectedEntityName = entityName;
SelectedEntityType = o.ToString();
Expand All @@ -460,17 +460,15 @@ protected void NavigateToProperty(object o, string entityName)
view.GroupDescriptions.Add(new DataGridPathGroupDescription(nameof(AvaloniaPropertyViewModel.Group)));
view.Filter = FilterProperty;
PropertiesView = view;

if (o is INotifyPropertyChanged inpc2)
{
inpc2.PropertyChanged += ControlPropertyChanged;
}

if (o is AvaloniaObject ao2)
if (o is IAvaloniaObject ao2)
{
ao2.PropertyChanged += ControlPropertyChanged;
}

else if (o is INotifyPropertyChanged inpc2)
{
inpc2.PropertyChanged += ControlPropertyChanged;
}
}
}
}

0 comments on commit 25de554

Please sign in to comment.