Skip to content

Commit 4c4d559

Browse files
committed
Fix crash when upgrading a document with a Modulo node from 3 commits ago
1 parent ee2d4a0 commit 4c4d559

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

editor/src/messages/portfolio/portfolio_message_handler.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
560560
}
561561

562562
// Upgrade Sine, Cosine, and Tangent nodes to include a boolean input for whether the output should be in radians, which was previously the only option but is now not the default
563-
// Also upgrade the Modulo node to include a boolean input for whether the output should be always positive, which was previously not an option
564-
if (reference == "Sine" || reference == "Cosine" || reference == "Tangent" || reference == "Modulo") && inputs_count == 1 {
563+
if (reference == "Sine" || reference == "Cosine" || reference == "Tangent") && inputs_count == 1 {
565564
let node_definition = resolve_document_node_type(reference).unwrap();
566565
let document_node = node_definition.default_node_template().document_node;
567566
document.network_interface.replace_implementation(node_id, &[], document_node.implementation.clone());
@@ -571,7 +570,22 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
571570
document.network_interface.set_input(&InputConnector::node(*node_id, 0), old_inputs[0].clone(), &[]);
572571
document
573572
.network_interface
574-
.set_input(&InputConnector::node(*node_id, 1), NodeInput::value(TaggedValue::Bool(reference != "Modulo"), false), &[]);
573+
.set_input(&InputConnector::node(*node_id, 1), NodeInput::value(TaggedValue::Bool(true), false), &[]);
574+
}
575+
576+
// Upgrade the Modulo node to include a boolean input for whether the output should be always positive, which was previously not an option
577+
if reference == "Modulo" && inputs_count == 2 {
578+
let node_definition = resolve_document_node_type(reference).unwrap();
579+
let document_node = node_definition.default_node_template().document_node;
580+
document.network_interface.replace_implementation(node_id, &[], document_node.implementation.clone());
581+
582+
let old_inputs = document.network_interface.replace_inputs(node_id, document_node.inputs.clone(), &[]);
583+
584+
document.network_interface.set_input(&InputConnector::node(*node_id, 0), old_inputs[0].clone(), &[]);
585+
document.network_interface.set_input(&InputConnector::node(*node_id, 1), old_inputs[1].clone(), &[]);
586+
document
587+
.network_interface
588+
.set_input(&InputConnector::node(*node_id, 2), NodeInput::value(TaggedValue::Bool(false), false), &[]);
575589
}
576590

577591
// Upgrade layer implementation from https://github.com/GraphiteEditor/Graphite/pull/1946

0 commit comments

Comments
 (0)