mirror of
https://codeberg.org/StreamGraph/StreamGraph.git
synced 2024-11-13 19:49:55 +01:00
fix connections being copied incorrectly (#42)
when copying nodes, incoming and outgoing connections could be copied in such a way that they had (empty) entries in the outgoing/incoming connections dictionaries despite not being connected to anything Reviewed-on: https://codeberg.org/Eroax/StreamGraph/pulls/42 Co-authored-by: Lera Elvoé <yagich@poto.cafe> Co-committed-by: Lera Elvoé <yagich@poto.cafe>
This commit is contained in:
parent
5a214c16f8
commit
0ebe17399d
1 changed files with 18 additions and 0 deletions
|
@ -307,6 +307,15 @@ func copy_nodes(nodes_to_copy: Array[String]) -> Dictionary:
|
||||||
if !(to_node in nodes_to_copy):
|
if !(to_node in nodes_to_copy):
|
||||||
(d.nodes[node].outgoing_connections[from_port] as Dictionary).erase(to_node)
|
(d.nodes[node].outgoing_connections[from_port] as Dictionary).erase(to_node)
|
||||||
|
|
||||||
|
var outgoing_is_empty: bool = true
|
||||||
|
for from_port: int in d.nodes[node].outgoing_connections:
|
||||||
|
if !(d.nodes[node].outgoing_connections[from_port] as Dictionary).is_empty():
|
||||||
|
outgoing_is_empty = false
|
||||||
|
break
|
||||||
|
|
||||||
|
if outgoing_is_empty:
|
||||||
|
d.nodes[node].outgoing_connections = {}
|
||||||
|
|
||||||
var incoming_connections: Dictionary = d.nodes[node].incoming_connections.duplicate(true)
|
var incoming_connections: Dictionary = d.nodes[node].incoming_connections.duplicate(true)
|
||||||
|
|
||||||
for to_port: int in incoming_connections:
|
for to_port: int in incoming_connections:
|
||||||
|
@ -314,6 +323,15 @@ func copy_nodes(nodes_to_copy: Array[String]) -> Dictionary:
|
||||||
if !(from_node in nodes_to_copy):
|
if !(from_node in nodes_to_copy):
|
||||||
(d.nodes[node].incoming_connections[to_port] as Dictionary).erase(from_node)
|
(d.nodes[node].incoming_connections[to_port] as Dictionary).erase(from_node)
|
||||||
|
|
||||||
|
var incoming_is_empty: bool = true
|
||||||
|
for to_port: int in d.nodes[node].incoming_connections:
|
||||||
|
if !(d.nodes[node].incoming_connections[to_port] as Dictionary).is_empty():
|
||||||
|
incoming_is_empty = false
|
||||||
|
break
|
||||||
|
|
||||||
|
if incoming_is_empty:
|
||||||
|
d.nodes[node].incoming_connections = {}
|
||||||
|
|
||||||
for node: Dictionary in d.nodes.values().slice(1):
|
for node: Dictionary in d.nodes.values().slice(1):
|
||||||
node.position.x = node.position.x - d.nodes.values()[0].position.x
|
node.position.x = node.position.x - d.nodes.values()[0].position.x
|
||||||
node.position.y = node.position.y - d.nodes.values()[0].position.y
|
node.position.y = node.position.y - d.nodes.values()[0].position.y
|
||||||
|
|
Loading…
Reference in a new issue