Skip to content

Commit

Permalink
Fix LayoutRoot references to deleted objects Dirkster99#171
Browse files Browse the repository at this point in the history
  • Loading branch information
LyonJack committed Jul 3, 2020
1 parent 7299695 commit 381c2e1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions source/Components/AvalonDock/Layout/LayoutGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This program is provided to you under the terms of the Microsoft Public
using System.Linq;
using System.Collections.ObjectModel;
using System.Xml.Serialization;
using System.Collections.Specialized;

namespace AvalonDock.Layout
{
Expand Down Expand Up @@ -212,17 +213,17 @@ protected override void OnParentChanged(ILayoutContainer oldValue, ILayoutContai

#region Private Methods

private void _children_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
private void _children_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove || e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace)
if (e.Action == NotifyCollectionChangedAction.Remove || e.Action == NotifyCollectionChangedAction.Replace)
{
if (e.OldItems != null)
{
foreach (LayoutElement element in e.OldItems)
if (element.Parent == this) element.Parent = null;
if (element.Parent == this || e.Action == NotifyCollectionChangedAction.Remove) element.Parent = null;
}
}
if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add || e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace)
if (e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Replace)
{
if (e.NewItems != null)
{
Expand All @@ -238,7 +239,7 @@ private void _children_CollectionChanged(object sender, System.Collections.Speci
ComputeVisibility();
OnChildrenCollectionChanged();

if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
if (e.Action == NotifyCollectionChangedAction.Add)
// #81 - Make parents update their children up the tree. Otherwise, they will not be redrawn.
RaiseChildrenTreeChanged();
else
Expand Down

0 comments on commit 381c2e1

Please sign in to comment.