_deserialize(): fix connection building: use actually created node's ids
@@ -1392,16 +1392,24 @@ class NodeGraph(QtCore.QObject):
'output_ports': n_data['output_ports']
})
+ def get_node_by_id(nid):
+ # if nid referes to a node created during deserialization,
+ # it may have a new id. get the new id.
+ if nid in nodes:
+ print(f'{nid}, {nodes[nid].id}')
+ nid = nodes[nid].id
+ return self.model.nodes.get(nid)
+
# build the connections.
for connection in data.get('connections', []):
nid, pname = connection.get('in', ('', ''))
- in_node = self.model.nodes.get(nid)
+ in_node = get_node_by_id(nid)
if not in_node:
continue
in_port = in_node.inputs().get(pname) if in_node else None
nid, pname = connection.get('out', ('', ''))
- out_node = self.model.nodes.get(nid)
+ out_node = get_node_by_id(nid)
if not out_node:
continue
out_port = out_node.outputs().get(pname) if out_node else None
