Skip to content

Commit 24c6281

Browse files
authored
Fix regression with migration code changed in node UI wire refactor (#2840)
Fixes
1 parent ce605ac commit 24c6281

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ impl<'a> ModifyInputsContext<'a> {
9797
};
9898
}
9999

100+
let layer_input_connector = post_node_input_connector.clone();
101+
100102
// Sink post_node down to the end of the non layer chain that feeds into post_node, such that pre_node is the layer node at insert_index + 1, or None if insert_index is the last layer
101103
loop {
102104
let pre_node_output_connector = network_interface.upstream_output_connector(&post_node_input_connector, &[]);
@@ -105,6 +107,11 @@ impl<'a> ModifyInputsContext<'a> {
105107
Some(OutputConnector::Node { node_id: pre_node_id, .. }) if !network_interface.is_layer(&pre_node_id, &[]) => {
106108
// Update post_node_input_connector for the next iteration
107109
post_node_input_connector = InputConnector::node(pre_node_id, 0);
110+
// Insert directly under layer if moving to the end of a layer stack that ends with a non layer node that does not have an exposed primary input
111+
let primary_is_exposed = network_interface.input_from_connector(&post_node_input_connector, &[]).is_some_and(|input| input.is_exposed());
112+
if !primary_is_exposed {
113+
return layer_input_connector;
114+
}
108115
}
109116
_ => break, // Break if pre_node_output_connector is None or if pre_node_id is a layer
110117
}

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4093,6 +4093,18 @@ impl NodeNetworkInterface {
40934093
}
40944094
}
40954095

4096+
// When opening an old document to ensure the output names match the number of exports
4097+
pub fn validate_output_names(&mut self, node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId]) {
4098+
if let DocumentNodeImplementation::Network(network) = &node.implementation {
4099+
let number_of_exports = network.exports.len();
4100+
let Some(metadata) = self.node_metadata_mut(node_id, network_path) else {
4101+
log::error!("Could not get metadata for node: {:?}", node_id);
4102+
return;
4103+
};
4104+
metadata.persistent_metadata.output_names.resize(number_of_exports, "".to_string());
4105+
}
4106+
}
4107+
40964108
/// Keep metadata in sync with the new implementation if this is used by anything other than the upgrade scripts
40974109
pub fn replace_reference_name(&mut self, node_id: &NodeId, network_path: &[NodeId], reference_name: String) {
40984110
let Some(node_metadata) = self.node_metadata_mut(node_id, network_path) else {
@@ -5639,7 +5651,6 @@ impl NodeNetworkInterface {
56395651
self.unload_all_nodes_bounding_box(network_path);
56405652
}
56415653

5642-
// TODO: Run the auto layout system to make space for the new nodes
56435654
/// Disconnect the layers primary output and the input to the last non layer node feeding into it through primary flow, reconnects, then moves the layer to the new layer and stack index
56445655
pub fn move_layer_to_stack(&mut self, layer: LayerNodeIdentifier, mut parent: LayerNodeIdentifier, mut insert_index: usize, network_path: &[NodeId]) {
56455656
// Prevent moving an artboard anywhere but to the ROOT_PARENT child stack

editor/src/messages/portfolio/document_migration.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -614,16 +614,15 @@ pub fn document_migration_upgrades(document: &mut DocumentMessageHandler, reset_
614614

615615
// Make the "Quantity" parameter a u32 instead of f64
616616
if reference == "Sample Polyline" {
617-
let node_definition = resolve_document_node_type("Sample Polyline").unwrap();
618-
let mut new_node_template = node_definition.default_node_template();
619-
620617
// Get the inputs, obtain the quantity value, and put the inputs back
621-
let old_inputs = document.network_interface.replace_inputs(node_id, network_path, &mut new_node_template).unwrap();
622-
let quantity_value = old_inputs.get(3).cloned();
618+
let quantity_value = document
619+
.network_interface
620+
.input_from_connector(&InputConnector::Node { node_id: *node_id, input_index: 3 }, network_path)
621+
.unwrap();
623622

624-
if let Some(NodeInput::Value { tagged_value, exposed }) = quantity_value {
625-
if let TaggedValue::F64(value) = *tagged_value {
626-
let new_quantity_value = NodeInput::value(TaggedValue::U32(value as u32), exposed);
623+
if let NodeInput::Value { tagged_value, exposed } = quantity_value {
624+
if let TaggedValue::F64(value) = **tagged_value {
625+
let new_quantity_value = NodeInput::value(TaggedValue::U32(value as u32), *exposed);
627626
document.network_interface.set_input(&InputConnector::node(*node_id, 3), new_quantity_value, network_path);
628627
}
629628
}

editor/src/messages/portfolio/portfolio_message_handler.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
431431
for (node_id, node, path) in document.network_interface.document_network().clone().recursive_nodes() {
432432
document.network_interface.validate_input_metadata(node_id, node, &path);
433433
document.network_interface.validate_display_name_metadata(node_id, &path);
434+
document.network_interface.validate_output_names(node_id, node, &path);
434435
}
435436

436437
// Ensure layers are positioned as stacks if they are upstream siblings of another layer

0 commit comments

Comments
 (0)