mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-07-07 15:55:00 +00:00
Fix regression with migration code changed in node UI wire refactor (#2840)
Fixes
This commit is contained in:
parent
ce605acf3a
commit
24c6281644
4 changed files with 27 additions and 9 deletions
|
@ -97,6 +97,8 @@ impl<'a> ModifyInputsContext<'a> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let layer_input_connector = post_node_input_connector.clone();
|
||||||
|
|
||||||
// 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
|
// 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
|
||||||
loop {
|
loop {
|
||||||
let pre_node_output_connector = network_interface.upstream_output_connector(&post_node_input_connector, &[]);
|
let pre_node_output_connector = network_interface.upstream_output_connector(&post_node_input_connector, &[]);
|
||||||
|
@ -105,6 +107,11 @@ impl<'a> ModifyInputsContext<'a> {
|
||||||
Some(OutputConnector::Node { node_id: pre_node_id, .. }) if !network_interface.is_layer(&pre_node_id, &[]) => {
|
Some(OutputConnector::Node { node_id: pre_node_id, .. }) if !network_interface.is_layer(&pre_node_id, &[]) => {
|
||||||
// Update post_node_input_connector for the next iteration
|
// Update post_node_input_connector for the next iteration
|
||||||
post_node_input_connector = InputConnector::node(pre_node_id, 0);
|
post_node_input_connector = InputConnector::node(pre_node_id, 0);
|
||||||
|
// 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
|
||||||
|
let primary_is_exposed = network_interface.input_from_connector(&post_node_input_connector, &[]).is_some_and(|input| input.is_exposed());
|
||||||
|
if !primary_is_exposed {
|
||||||
|
return layer_input_connector;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => break, // Break if pre_node_output_connector is None or if pre_node_id is a layer
|
_ => break, // Break if pre_node_output_connector is None or if pre_node_id is a layer
|
||||||
}
|
}
|
||||||
|
|
|
@ -4093,6 +4093,18 @@ impl NodeNetworkInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When opening an old document to ensure the output names match the number of exports
|
||||||
|
pub fn validate_output_names(&mut self, node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId]) {
|
||||||
|
if let DocumentNodeImplementation::Network(network) = &node.implementation {
|
||||||
|
let number_of_exports = network.exports.len();
|
||||||
|
let Some(metadata) = self.node_metadata_mut(node_id, network_path) else {
|
||||||
|
log::error!("Could not get metadata for node: {:?}", node_id);
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
metadata.persistent_metadata.output_names.resize(number_of_exports, "".to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Keep metadata in sync with the new implementation if this is used by anything other than the upgrade scripts
|
/// Keep metadata in sync with the new implementation if this is used by anything other than the upgrade scripts
|
||||||
pub fn replace_reference_name(&mut self, node_id: &NodeId, network_path: &[NodeId], reference_name: String) {
|
pub fn replace_reference_name(&mut self, node_id: &NodeId, network_path: &[NodeId], reference_name: String) {
|
||||||
let Some(node_metadata) = self.node_metadata_mut(node_id, network_path) else {
|
let Some(node_metadata) = self.node_metadata_mut(node_id, network_path) else {
|
||||||
|
@ -5639,7 +5651,6 @@ impl NodeNetworkInterface {
|
||||||
self.unload_all_nodes_bounding_box(network_path);
|
self.unload_all_nodes_bounding_box(network_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Run the auto layout system to make space for the new nodes
|
|
||||||
/// 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
|
/// 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
|
||||||
pub fn move_layer_to_stack(&mut self, layer: LayerNodeIdentifier, mut parent: LayerNodeIdentifier, mut insert_index: usize, network_path: &[NodeId]) {
|
pub fn move_layer_to_stack(&mut self, layer: LayerNodeIdentifier, mut parent: LayerNodeIdentifier, mut insert_index: usize, network_path: &[NodeId]) {
|
||||||
// Prevent moving an artboard anywhere but to the ROOT_PARENT child stack
|
// Prevent moving an artboard anywhere but to the ROOT_PARENT child stack
|
||||||
|
|
|
@ -614,16 +614,15 @@ pub fn document_migration_upgrades(document: &mut DocumentMessageHandler, reset_
|
||||||
|
|
||||||
// Make the "Quantity" parameter a u32 instead of f64
|
// Make the "Quantity" parameter a u32 instead of f64
|
||||||
if reference == "Sample Polyline" {
|
if reference == "Sample Polyline" {
|
||||||
let node_definition = resolve_document_node_type("Sample Polyline").unwrap();
|
|
||||||
let mut new_node_template = node_definition.default_node_template();
|
|
||||||
|
|
||||||
// Get the inputs, obtain the quantity value, and put the inputs back
|
// Get the inputs, obtain the quantity value, and put the inputs back
|
||||||
let old_inputs = document.network_interface.replace_inputs(node_id, network_path, &mut new_node_template).unwrap();
|
let quantity_value = document
|
||||||
let quantity_value = old_inputs.get(3).cloned();
|
.network_interface
|
||||||
|
.input_from_connector(&InputConnector::Node { node_id: *node_id, input_index: 3 }, network_path)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
if let Some(NodeInput::Value { tagged_value, exposed }) = quantity_value {
|
if let NodeInput::Value { tagged_value, exposed } = quantity_value {
|
||||||
if let TaggedValue::F64(value) = *tagged_value {
|
if let TaggedValue::F64(value) = **tagged_value {
|
||||||
let new_quantity_value = NodeInput::value(TaggedValue::U32(value as u32), exposed);
|
let new_quantity_value = NodeInput::value(TaggedValue::U32(value as u32), *exposed);
|
||||||
document.network_interface.set_input(&InputConnector::node(*node_id, 3), new_quantity_value, network_path);
|
document.network_interface.set_input(&InputConnector::node(*node_id, 3), new_quantity_value, network_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -431,6 +431,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
|
||||||
for (node_id, node, path) in document.network_interface.document_network().clone().recursive_nodes() {
|
for (node_id, node, path) in document.network_interface.document_network().clone().recursive_nodes() {
|
||||||
document.network_interface.validate_input_metadata(node_id, node, &path);
|
document.network_interface.validate_input_metadata(node_id, node, &path);
|
||||||
document.network_interface.validate_display_name_metadata(node_id, &path);
|
document.network_interface.validate_display_name_metadata(node_id, &path);
|
||||||
|
document.network_interface.validate_output_names(node_id, node, &path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure layers are positioned as stacks if they are upstream siblings of another layer
|
// Ensure layers are positioned as stacks if they are upstream siblings of another layer
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue