From 408a125658f1c6c1ef9427da10443eadd0f9dcee Mon Sep 17 00:00:00 2001 From: Simon Rodriguez Date: Tue, 9 Jul 2019 22:07:09 +0200 Subject: [PATCH] clear connections before removing port, so the connected nodes don't have invalid references. --- Scripts/NodeDataCache.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Scripts/NodeDataCache.cs b/Scripts/NodeDataCache.cs index d7fa38c..70efd64 100644 --- a/Scripts/NodeDataCache.cs +++ b/Scripts/NodeDataCache.cs @@ -30,11 +30,16 @@ namespace XNode { NodePort staticPort; if (staticPorts.TryGetValue(port.fieldName, out staticPort)) { // If port exists but with wrong settings, remove it. Re-add it later. - if (port.connectionType != staticPort.connectionType || port.IsDynamic || port.direction != staticPort.direction || port.typeConstraint != staticPort.typeConstraint) ports.Remove(port.fieldName); - else port.ValueType = staticPort.ValueType; + if (port.IsDynamic || port.direction != staticPort.direction || port.connectionType != staticPort.connectionType || port.typeConstraint != staticPort.typeConstraint) { + port.ClearConnections(); + ports.Remove(port.fieldName); + } else port.ValueType = staticPort.ValueType; } // If port doesn't exist anymore, remove it - else if (port.IsStatic) ports.Remove(port.fieldName); + else if (port.IsStatic) { + port.ClearConnections(); + ports.Remove(port.fieldName); + } } // Add missing ports foreach (NodePort staticPort in staticPorts.Values) {