Browse Source

Think I've managed to repro Core2D leak.

pull/467/head
Steven Kirk 10 years ago
parent
commit
913c647bcb
  1. 2
      samples/BindingTest/TestItemView.paml
  2. 2
      samples/BindingTest/ViewModels/MainWindowViewModel.cs
  3. 12
      src/Perspex.Base/Collections/InccDebug.cs
  4. 5
      src/Perspex.Base/Collections/PerspexList.cs
  5. 1
      src/Perspex.Base/Perspex.Base.csproj
  6. 5
      src/Perspex.Controls/Control.cs

2
samples/BindingTest/TestItemView.paml

@ -1,6 +1,6 @@
<UserControl xmlns="https://github.com/perspex">
<StackPanel>
<TextBlock Classes="h1" Text="{Binding StringValue}"/>
<TextBlock Text="{Binding Detail}"/>
<TextBox Text="{Binding Detail}" AcceptsReturn="True"/>
</StackPanel>
</UserControl>

2
samples/BindingTest/ViewModels/MainWindowViewModel.cs

@ -17,7 +17,7 @@ namespace BindingTest.ViewModels
Enumerable.Range(0, 20).Select(x => new TestItem
{
StringValue = "Item " + x,
Detail = "Item " + " details",
Detail = "Item " + x + " details",
}));
SelectedItems = new ObservableCollection<TestItem>();

12
src/Perspex.Base/Collections/InccDebug.cs

@ -0,0 +1,12 @@
// Copyright (c) The Perspex Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
namespace Perspex.Collections
{
public interface InccDebug
{
Delegate[] GetCollectionChangedSubscribers();
}
}

5
src/Perspex.Base/Collections/PerspexList.cs

@ -53,7 +53,7 @@ namespace Perspex.Collections
/// </item>
/// </list>
/// </remarks>
public class PerspexList<T> : IPerspexList<T>, IList
public class PerspexList<T> : IPerspexList<T>, IList, InccDebug
{
private List<T> _inner;
private NotifyCollectionChangedEventHandler _collectionChanged;
@ -434,6 +434,9 @@ namespace Perspex.Collections
return _inner.GetEnumerator();
}
/// <inheritdoc/>
Delegate[] InccDebug.GetCollectionChangedSubscribers() => _collectionChanged?.GetInvocationList();
/// <summary>
/// Raises the <see cref="CollectionChanged"/> event with an add action.
/// </summary>

1
src/Perspex.Base/Perspex.Base.csproj

@ -43,6 +43,7 @@
<Compile Include="..\Shared\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Collections\InccDebug.cs" />
<Compile Include="Data\AssignBindingAttribute.cs" />
<Compile Include="Data\BindingOperations.cs" />
<Compile Include="Data\InstancedBinding.cs" />

5
src/Perspex.Controls/Control.cs

@ -528,6 +528,11 @@ namespace Perspex.Controls
{
child.OnDetachedFromLogicalTree(e);
}
if (((InccDebug)_classes).GetCollectionChangedSubscribers()?.Length > 0)
{
System.Diagnostics.Debugger.Break();
}
}
/// <inheritdoc/>

Loading…
Cancel
Save