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

Fix OnRemoveConnection from calling side

If we use the original:
if (port != null && port.IsConnectedTo(this)) port.node.OnRemoveConnection(port);
we going to have always wrong condition, about "IsConnectedTo(this)" and port.node.OnRemoveConnection(port) just won't be called, cause we already have disconnected ports. So we need to do it exactly at the moment of disconnection.
This commit is contained in:
RomanZanevski 2022-04-25 16:24:08 +02:00 committed by GitHub
parent 286b9a167a
commit 46076527f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -296,12 +296,13 @@ namespace XNode {
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 from this side port
port.node.OnRemoveConnection(port);
} }
} }
} }
// Trigger OnRemoveConnection // Trigger OnRemoveConnection
node.OnRemoveConnection(this); node.OnRemoveConnection(this);
if (port != null && port.IsConnectedTo(this)) port.node.OnRemoveConnection(port);
} }
/// <summary> Disconnect this port from another port </summary> /// <summary> Disconnect this port from another port </summary>
@ -413,4 +414,4 @@ namespace XNode {
} }
} }
} }
} }