Skip to content

Commit 50f06c8

Browse files
committed
Fix crash from #3160 when migrating some old documents to use degrees not radians
1 parent 929dbdb commit 50f06c8

1 file changed

Lines changed: 22 additions & 15 deletions

File tree

editor/src/messages/portfolio/document_migration.rs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,23 +1100,30 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
11001100
document.network_interface.set_input(&InputConnector::node(*node_id, 4), new_input, network_path);
11011101
}
11021102

1103-
// Remove the possible existence of the old "Pivot" hidden value input that was removed in #2730
1104-
let nested_transform_network = [network_path, &[*node_id]].concat();
1105-
if node.inputs.get(5).is_some() {
1106-
document.network_interface.remove_import(5, &nested_transform_network);
1107-
}
1108-
1109-
// Add the Origin Offset parameter as a hidden input, which will be given actual functionality in the future but is currently used as a marker to detect not-yet-upgraded Transform nodes
1110-
document
1103+
if document
11111104
.network_interface
1112-
.add_import(TaggedValue::DVec2(DVec2::ZERO), false, 5, "Origin Offset", "", &nested_transform_network);
1113-
document.network_interface.set_input_override(node_id, 5, Some("hidden".to_string()), network_path); // Hide it while we're not yet using it
1105+
.node_metadata(node_id, network_path)
1106+
.map(|x| x.persistent_metadata.input_metadata.len() > 5)
1107+
.unwrap_or_default()
1108+
{
1109+
// Remove the possible existence of the old "Pivot" hidden value input that was removed in #2730
1110+
let nested_transform_network = [network_path, &[*node_id]].concat();
1111+
if node.inputs.get(5).is_some() {
1112+
document.network_interface.remove_import(5, &nested_transform_network);
1113+
}
11141114

1115-
// Add the Scale Appearance parameter as a hidden input, which will be given actual functionality in the future but is currently used as a marker to detect not-yet-upgraded Transform nodes
1116-
document
1117-
.network_interface
1118-
.add_import(TaggedValue::Bool(true), false, 6, "Scale Appearance", "", &nested_transform_network);
1119-
document.network_interface.set_input_override(node_id, 6, Some("hidden".to_string()), network_path); // Hide it while we're not yet using it
1115+
// Add the Origin Offset parameter as a hidden input, which will be given actual functionality in the future but is currently used as a marker to detect not-yet-upgraded Transform nodes
1116+
document
1117+
.network_interface
1118+
.add_import(TaggedValue::DVec2(DVec2::ZERO), false, 5, "Origin Offset", "", &nested_transform_network);
1119+
document.network_interface.set_input_override(node_id, 5, Some("hidden".to_string()), network_path); // Hide it while we're not yet using it
1120+
1121+
// Add the Scale Appearance parameter as a hidden input, which will be given actual functionality in the future but is currently used as a marker to detect not-yet-upgraded Transform nodes
1122+
document
1123+
.network_interface
1124+
.add_import(TaggedValue::Bool(true), false, 6, "Scale Appearance", "", &nested_transform_network);
1125+
document.network_interface.set_input_override(node_id, 6, Some("hidden".to_string()), network_path); // Hide it while we're not yet using it
1126+
}
11201127
}
11211128

11221129
// Add context features to nodes that don't have them (fine-grained context caching migration)

0 commit comments

Comments
 (0)