From 9d0e4e9768b91e33bfeb2739038bfb0724f3c855 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 25 Mar 2026 18:51:12 +0100 Subject: [PATCH] Fix potential stack overflow inside `CustomEditor.RebuildLayout` #3720 --- Source/Editor/CustomEditors/CustomEditor.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Editor/CustomEditors/CustomEditor.cs b/Source/Editor/CustomEditors/CustomEditor.cs index ff9a14ea3..253fbc590 100644 --- a/Source/Editor/CustomEditors/CustomEditor.cs +++ b/Source/Editor/CustomEditors/CustomEditor.cs @@ -52,6 +52,7 @@ namespace FlaxEditor.CustomEditors private readonly List _children = new List(); private ValueContainer _values; private bool _isSetBlocked; + private bool _isRebuilding; private bool _skipChildrenRefresh; private bool _hasValueDirty; private bool _rebuildOnRefresh; @@ -178,7 +179,7 @@ namespace FlaxEditor.CustomEditors public void RebuildLayout() { // Skip rebuilding during init - if (CurrentCustomEditor == this) + if (CurrentCustomEditor == this || _isRebuilding) return; // Special case for root objects to run normal layout build @@ -197,6 +198,7 @@ namespace FlaxEditor.CustomEditors _parent?.RebuildLayout(); return; } + _isRebuilding = true; var control = layout.ContainerControl; var parent = _parent; var parentScrollV = (_presenter?.Panel.Parent as Panel)?.VScrollBar?.Value ?? -1; @@ -216,6 +218,7 @@ namespace FlaxEditor.CustomEditors // Restore scroll value if (parentScrollV > -1 && _presenter != null && _presenter.Panel.Parent is Panel panel && panel.VScrollBar != null) panel.VScrollBar.Value = parentScrollV; + _isRebuilding = false; } ///