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:
1 file changed
+2
-1
@@ -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];
|
||||
|
||||
|
||||
Reference in new issue
Block a user