fix(ui-visuals): guard preview layers during base construction

The base constructor sets an inherited property, which can enumerate visual
children before the surface's layer collection is assigned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 10:28:13 +00:00
1 parent b0c5790adb
commit 75508395c3
1 file changed
+2 -1
+2 -1
View File
@@ -45,7 +45,8 @@ public sealed class PreviewSurface : DrawingElement
/// <summary>Viewport whose properties drive the layers.</summary>
internal PreviewViewport? Owner { get; set; }
protected override int VisualChildrenCount => _layers.Count;
// The base constructor sets an inherited property, which may enumerate children before _layers exists.
protected override int VisualChildrenCount => _layers is null ? 0 : _layers.Count;
protected override Visual GetVisualChild(int index) => _layers[index];