Skip to content

Commit 793fef9

Browse files
_deserialize(): fix connection building: use actually created node's ids
1 parent 96cd815 commit 793fef9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

NodeGraphQt/base/graph.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,16 +1392,24 @@ def _deserialize(self, data, relative_pos=False, pos=None, set_parent=True):
13921392
'output_ports': n_data['output_ports']
13931393
})
13941394

1395+
def get_node_by_id(nid):
1396+
# if nid referes to a node created during deserialization,
1397+
# it may have a new id. get the new id.
1398+
if nid in nodes:
1399+
print(f'{nid}, {nodes[nid].id}')
1400+
nid = nodes[nid].id
1401+
return self.model.nodes.get(nid)
1402+
13951403
# build the connections.
13961404
for connection in data.get('connections', []):
13971405
nid, pname = connection.get('in', ('', ''))
1398-
in_node = self.model.nodes.get(nid)
1406+
in_node = get_node_by_id(nid)
13991407
if not in_node:
14001408
continue
14011409
in_port = in_node.inputs().get(pname) if in_node else None
14021410

14031411
nid, pname = connection.get('out', ('', ''))
1404-
out_node = self.model.nodes.get(nid)
1412+
out_node = get_node_by_id(nid)
14051413
if not out_node:
14061414
continue
14071415
out_port = out_node.outputs().get(pname) if out_node else None

0 commit comments

Comments
 (0)