Browse Source

Merge pull request #6839 from workgroupengineering/fixes/Issue_6838

fixes(DevTools): Double subscribe/unsubscribe INotifyPropertyChanged
pull/6851/head
Max Katz 5 years ago
committed by GitHub
parent
commit
1eeaedaf65
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs

24
src/Avalonia.Diagnostics/Diagnostics/ViewModels/ControlDetailsViewModel.cs

@ -423,16 +423,16 @@ namespace Avalonia.Diagnostics.ViewModels
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();
@ -448,17 +448,15 @@ namespace Avalonia.Diagnostics.ViewModels
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;
}
}
}
}

Loading…
Cancel
Save