From 50f06c886f6137bf0b54bb6930cbb08608beeef4 Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Thu, 11 Sep 2025 15:14:41 -0700 Subject: [PATCH] Fix crash from #3160 when migrating some old documents to use degrees not radians --- .../messages/portfolio/document_migration.rs | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/editor/src/messages/portfolio/document_migration.rs b/editor/src/messages/portfolio/document_migration.rs index 1132ec07..27892fa4 100644 --- a/editor/src/messages/portfolio/document_migration.rs +++ b/editor/src/messages/portfolio/document_migration.rs @@ -1100,23 +1100,30 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId], document.network_interface.set_input(&InputConnector::node(*node_id, 4), new_input, network_path); } - // Remove the possible existence of the old "Pivot" hidden value input that was removed in #2730 - let nested_transform_network = [network_path, &[*node_id]].concat(); - if node.inputs.get(5).is_some() { - document.network_interface.remove_import(5, &nested_transform_network); + if document + .network_interface + .node_metadata(node_id, network_path) + .map(|x| x.persistent_metadata.input_metadata.len() > 5) + .unwrap_or_default() + { + // Remove the possible existence of the old "Pivot" hidden value input that was removed in #2730 + let nested_transform_network = [network_path, &[*node_id]].concat(); + if node.inputs.get(5).is_some() { + document.network_interface.remove_import(5, &nested_transform_network); + } + + // 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 + document + .network_interface + .add_import(TaggedValue::DVec2(DVec2::ZERO), false, 5, "Origin Offset", "", &nested_transform_network); + document.network_interface.set_input_override(node_id, 5, Some("hidden".to_string()), network_path); // Hide it while we're not yet using it + + // 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 + document + .network_interface + .add_import(TaggedValue::Bool(true), false, 6, "Scale Appearance", "", &nested_transform_network); + document.network_interface.set_input_override(node_id, 6, Some("hidden".to_string()), network_path); // Hide it while we're not yet using it } - - // 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 - document - .network_interface - .add_import(TaggedValue::DVec2(DVec2::ZERO), false, 5, "Origin Offset", "", &nested_transform_network); - document.network_interface.set_input_override(node_id, 5, Some("hidden".to_string()), network_path); // Hide it while we're not yet using it - - // 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 - document - .network_interface - .add_import(TaggedValue::Bool(true), false, 6, "Scale Appearance", "", &nested_transform_network); - document.network_interface.set_input_override(node_id, 6, Some("hidden".to_string()), network_path); // Hide it while we're not yet using it } // Add context features to nodes that don't have them (fine-grained context caching migration)