From 66a67ad100abb1f92b261bfdeb0653d1ffb1f226 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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Bonsai.Editor/Layout/LayoutHelper.cs b/Bonsai.Editor/Layout/LayoutHelper.cs index 1f205ae66..ee02a7f85 100644 --- a/Bonsai.Editor/Layout/LayoutHelper.cs +++ b/Bonsai.Editor/Layout/LayoutHelper.cs @@ -193,8 +193,13 @@ static IReadOnlyList GetMashupArguments(InspectBuilder builde if (visualizerMappings.Count == 0) return Array.Empty(); return visualizerMappings.Select(mapping => { - var nestedSources = GetMashupArguments(mapping.Source, typeVisualizerMap); + // mapping.Source == builder if two visualizers in the mashup visualize the same node + var nestedSources = mapping.Source == builder + ? throw new WorkflowBuildException("Visualizer mappings of same node are combined together.", builder) + : GetMashupArguments(mapping.Source, typeVisualizerMap); + var visualizerType = mapping.VisualizerType ?? typeVisualizerMap.GetTypeVisualizers(mapping.Source).FirstOrDefault(); + return new VisualizerFactory(mapping.Source, visualizerType, nestedSources); }).ToList(); }