From 888782c1aca4d8394ec4f49dc8372599dcded1c0 Mon Sep 17 00:00:00 2001 From: glopesdev Date: Tue, 27 Sep 2022 13:15:10 +0100 Subject: [PATCH] Ensure nested mashup sources are always serialized --- Bonsai.Editor/Layout/LayoutHelper.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Bonsai.Editor/Layout/LayoutHelper.cs b/Bonsai.Editor/Layout/LayoutHelper.cs index 647f718a2..1f205ae66 100644 --- a/Bonsai.Editor/Layout/LayoutHelper.cs +++ b/Bonsai.Editor/Layout/LayoutHelper.cs @@ -273,16 +273,13 @@ static void SerializeMashupVisualizerSettings( foreach (var source in mashupVisualizer.MashupSources) { var sourceIndex = GetMashupSourceIndex(source, topologicalOrder); - if (sourceIndex.HasValue) - { - var mashupSource = SerializeMashupSource(sourceIndex.Value, source.Visualizer, topologicalOrder); - root.Add(mashupSource); - } + var mashupSource = SerializeMashupSource(sourceIndex, source.Visualizer, topologicalOrder); + root.Add(mashupSource); } } static XElement SerializeMashupSource( - int sourceIndex, + int? sourceIndex, DialogTypeVisualizer visualizer, IEnumerable> topologicalOrder) { @@ -301,7 +298,7 @@ static XElement SerializeMashupSource( visualizerSettings = new XDocument( new XElement(MashupSettingsElement, - new XElement(MashupSourceElement, sourceIndex), + sourceIndex.HasValue ? new XElement(MashupSourceElement, sourceIndex.Value) : null, new XElement(nameof(VisualizerDialogSettings.VisualizerTypeName), visualizerType.FullName), new XElement(nameof(VisualizerDialogSettings.VisualizerSettings), visualizerSettings.Root))); return visualizerSettings.Root;