Skip to content

Commit 1b9a492

Browse files
authored
Fix crash when creating cyclic nodes (#3313)
* Fix crash when creating cyclic nodes * Re-add the recursive set_input call
1 parent 40c6c61 commit 1b9a492

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

editor/src/messages/portfolio/document/utility_types/network_interface.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4262,11 +4262,6 @@ impl NodeNetworkInterface {
42624262
}
42634263
}
42644264

4265-
let previous_metadata = match &previous_input {
4266-
NodeInput::Node { node_id, .. } => self.position(node_id, network_path).map(|position| (*node_id, position)),
4267-
_ => None,
4268-
};
4269-
42704265
let Some(network) = self.network_mut(network_path) else {
42714266
log::error!("Could not get nested network in set_input");
42724267
return;
@@ -4303,6 +4298,12 @@ impl NodeNetworkInterface {
43034298
return;
43044299
}
43054300

4301+
// It is necessary to ensure the grpah is acyclic before calling `self.position` as it sometimes crashes with cyclic graphs #3227
4302+
let previous_metadata = match &previous_input {
4303+
NodeInput::Node { node_id, .. } => self.position(node_id, network_path).map(|position| (*node_id, position)),
4304+
_ => None,
4305+
};
4306+
43064307
self.transaction_modified();
43074308

43084309
// Ensure layer is toggled to non layer if it is no longer eligible to be a layer

0 commit comments

Comments
 (0)