1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-20 17:26:02 +08:00

Fixed NullRefEx when trying to disconnect a null NodePort

This commit is contained in:
Thor Brigsted 2018-02-02 12:29:19 +01:00
parent 51e77a2279
commit 1b2f94607e

View File

@ -54,8 +54,7 @@ namespace XNode {
if (attribs[i] is Node.InputAttribute) { if (attribs[i] is Node.InputAttribute) {
_direction = IO.Input; _direction = IO.Input;
_connectionType = (attribs[i] as Node.InputAttribute).connectionType; _connectionType = (attribs[i] as Node.InputAttribute).connectionType;
} } else if (attribs[i] is Node.OutputAttribute) {
else if (attribs[i] is Node.OutputAttribute) {
_direction = IO.Output; _direction = IO.Output;
_connectionType = (attribs[i] as Node.OutputAttribute).connectionType; _connectionType = (attribs[i] as Node.OutputAttribute).connectionType;
} }
@ -225,15 +224,17 @@ namespace XNode {
connections.RemoveAt(i); connections.RemoveAt(i);
} }
} }
if (port != null) {
// Remove the other ports connection to this port // Remove the other ports connection to this port
for (int i = 0; i < port.connections.Count; i++) { for (int i = 0; i < port.connections.Count; i++) {
if (port.connections[i].Port == this) { if (port.connections[i].Port == this) {
port.connections.RemoveAt(i); port.connections.RemoveAt(i);
} }
} }
}
// Trigger OnRemoveConnection // Trigger OnRemoveConnection
node.OnRemoveConnection(this); node.OnRemoveConnection(this);
port.node.OnRemoveConnection(port); if (port != null) port.node.OnRemoveConnection(port);
} }
public void ClearConnections() { public void ClearConnections() {