|
|
@ -113,6 +113,11 @@ namespace Avalonia.Rendering.SceneGraph |
|
|
/// <param name="child">The child to add.</param>
|
|
|
/// <param name="child">The child to add.</param>
|
|
|
public void AddChild(IVisualNode child) |
|
|
public void AddChild(IVisualNode child) |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (child.Disposed) |
|
|
|
|
|
{ |
|
|
|
|
|
throw new ObjectDisposedException("Visual node for {node.Visual}"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
EnsureChildrenCreated(); |
|
|
EnsureChildrenCreated(); |
|
|
_children.Add(child); |
|
|
_children.Add(child); |
|
|
} |
|
|
} |
|
|
@ -135,7 +140,6 @@ namespace Avalonia.Rendering.SceneGraph |
|
|
{ |
|
|
{ |
|
|
EnsureChildrenCreated(); |
|
|
EnsureChildrenCreated(); |
|
|
_children.Remove(child); |
|
|
_children.Remove(child); |
|
|
child.Dispose(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
@ -145,13 +149,13 @@ namespace Avalonia.Rendering.SceneGraph |
|
|
/// <param name="node">The child to add.</param>
|
|
|
/// <param name="node">The child to add.</param>
|
|
|
public void ReplaceChild(int index, IVisualNode node) |
|
|
public void ReplaceChild(int index, IVisualNode node) |
|
|
{ |
|
|
{ |
|
|
EnsureChildrenCreated(); |
|
|
if (node.Disposed) |
|
|
var old = _children[index]; |
|
|
|
|
|
_children[index] = node; |
|
|
|
|
|
if (node != old) |
|
|
|
|
|
{ |
|
|
{ |
|
|
old.Dispose(); |
|
|
throw new ObjectDisposedException("Visual node for {node.Visual}"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
EnsureChildrenCreated(); |
|
|
|
|
|
_children[index] = node; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
@ -332,13 +336,11 @@ namespace Avalonia.Rendering.SceneGraph |
|
|
_drawOperationsCloned = false; |
|
|
_drawOperationsCloned = false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public bool Disposed { get; } |
|
|
|
|
|
|
|
|
public void Dispose() |
|
|
public void Dispose() |
|
|
{ |
|
|
{ |
|
|
foreach (var child in Children) |
|
|
|
|
|
{ |
|
|
|
|
|
child.Dispose(); |
|
|
|
|
|
} |
|
|
|
|
|
_drawOperationsRefCounter?.Dispose(); |
|
|
_drawOperationsRefCounter?.Dispose(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|