1
0
mirror of https://github.com/Siccity/xNode.git synced 2026-03-26 22:49:02 +08:00

clear connections before removing port, so the connected nodes don't have invalid references.

This commit is contained in:
Simon Rodriguez 2019-07-09 22:07:09 +02:00
parent 6a629d159c
commit 408a125658

View File

@ -30,11 +30,16 @@ namespace XNode {
NodePort staticPort; NodePort staticPort;
if (staticPorts.TryGetValue(port.fieldName, out staticPort)) { if (staticPorts.TryGetValue(port.fieldName, out staticPort)) {
// If port exists but with wrong settings, remove it. Re-add it later. // 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); if (port.IsDynamic || port.direction != staticPort.direction || port.connectionType != staticPort.connectionType || port.typeConstraint != staticPort.typeConstraint) {
else port.ValueType = staticPort.ValueType; port.ClearConnections();
ports.Remove(port.fieldName);
} else port.ValueType = staticPort.ValueType;
} }
// If port doesn't exist anymore, remove it // 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 // Add missing ports
foreach (NodePort staticPort in staticPorts.Values) { foreach (NodePort staticPort in staticPorts.Values) {