Browse Source

Clean up when node removed.

pull/3469/head
Steven Kirk 7 years ago
parent
commit
bd022cca39
  1. 1
      src/Avalonia.Controls/SelectionNode.cs
  2. 14
      tests/Avalonia.Controls.UnitTests/SelectionModelTests.cs

1
src/Avalonia.Controls/SelectionNode.cs

@ -655,6 +655,7 @@ namespace Avalonia.Controls
if (_childrenNodes[index] != null) if (_childrenNodes[index] != null)
{ {
RealizedChildrenNodeCount--; RealizedChildrenNodeCount--;
_childrenNodes[index]!.Dispose();
} }
_childrenNodes.RemoveAt(index); _childrenNodes.RemoveAt(index);
} }

14
tests/Avalonia.Controls.UnitTests/SelectionModelTests.cs

@ -964,6 +964,20 @@ namespace Avalonia.Controls.UnitTests
} }
} }
[Fact]
public void Removing_Item_Unhooks_CollectionChanged_Handlers()
{
var data = CreateNestedData(2, 2, 2);
var target = new SelectionModel { Source = data };
target.SelectAll();
var toRemove = (AvaloniaList<object>)data[1];
data.Remove(toRemove);
Assert.Equal(0, GetSubscriberCount(toRemove));
}
[Fact] [Fact]
public void Should_Not_Treat_Strings_As_Nested_Selections() public void Should_Not_Treat_Strings_As_Nested_Selections()
{ {

Loading…
Cancel
Save