Browse Source
Merge pull request #2793 from AvaloniaUI/fixes/visualnode-nre
Fix NRE in VisualNode.SortChildren.
pull/2805/head
Nikita Tsukanov
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
15 additions and
1 deletions
-
src/Avalonia.Visuals/Rendering/SceneGraph/VisualNode.cs
-
tests/Avalonia.Visuals.UnitTests/Rendering/SceneGraph/VisualNodeTests.cs
|
|
|
@ -179,7 +179,12 @@ namespace Avalonia.Rendering.SceneGraph |
|
|
|
/// <param name="scene">The scene that the node is a part of.</param>
|
|
|
|
public void SortChildren(Scene scene) |
|
|
|
{ |
|
|
|
var keys = new List<long>(); |
|
|
|
if (_children == null || _children.Count <= 1) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var keys = new List<long>(Visual.VisualChildren.Count); |
|
|
|
|
|
|
|
for (var i = 0; i < Visual.VisualChildren.Count; ++i) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -92,5 +92,14 @@ namespace Avalonia.Visuals.UnitTests.Rendering.SceneGraph |
|
|
|
Assert.Same(node1.DrawOperations[0].Item, node2.DrawOperations[0].Item); |
|
|
|
Assert.NotSame(node1.DrawOperations[0], node2.DrawOperations[0]); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void SortChildren_Does_Not_Throw_On_Null_Children() |
|
|
|
{ |
|
|
|
var node = new VisualNode(Mock.Of<IVisual>(), null); |
|
|
|
var scene = new Scene(Mock.Of<IVisual>()); |
|
|
|
|
|
|
|
node.SortChildren(scene); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|