From 04f2db6cf6ecf0646d402732ea2fee419ab3c493 Mon Sep 17 00:00:00 2001 From: David Maas Date: Thu, 9 May 2024 20:36:44 -0500 Subject: [PATCH] Prevent infinite recursion when visualizer mappings of the same node are combined together Fixes https://github.com/bonsai-rx/bonsai/issues/1769 --- Bonsai.Editor/Layout/LayoutHelper.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Bonsai.Editor/Layout/LayoutHelper.cs b/Bonsai.Editor/Layout/LayoutHelper.cs index 1f205ae66..3047766f4 100644 --- a/Bonsai.Editor/Layout/LayoutHelper.cs +++ b/Bonsai.Editor/Layout/LayoutHelper.cs @@ -193,6 +193,10 @@ static IReadOnlyList GetMashupArguments(InspectBuilder builde if (visualizerMappings.Count == 0) return Array.Empty(); return visualizerMappings.Select(mapping => { + // stack overflow happens if a visualizer ends up being mapped to itself + if (mapping.Source == builder) + throw new WorkflowBuildException("Combining together visualizer mappings from the same node is not currently supported.", builder); + var nestedSources = GetMashupArguments(mapping.Source, typeVisualizerMap); var visualizerType = mapping.VisualizerType ?? typeVisualizerMap.GetTypeVisualizers(mapping.Source).FirstOrDefault(); return new VisualizerFactory(mapping.Source, visualizerType, nestedSources);