Skip to content

Commit 869967c

Browse files
committed
Fix remove handles migration
1 parent baf4452 commit 869967c

File tree

2 files changed

+46
-32
lines changed

2 files changed

+46
-32
lines changed

editor/src/messages/portfolio/document_migration.rs

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,13 +1034,13 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
10341034
}
10351035

10361036
// Only nodes that have not been modified and still refer to a definition can be updated
1037-
let reference = &document.network_interface.reference(node_id, network_path)?;
1037+
let reference = document.network_interface.reference(node_id, network_path)?;
10381038

10391039
let inputs_count = node.inputs.len();
10401040

10411041
// Upgrade Stroke node to reorder parameters and add "Align" and "Paint Order" (#2644)
1042-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::vector::solidify_stroke::IDENTIFIER) && inputs_count == 8 {
1043-
let mut node_template = resolve_document_node_type(reference)?.default_node_template();
1042+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::solidify_stroke::IDENTIFIER) && inputs_count == 8 {
1043+
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
10441044
let old_inputs = document.network_interface.replace_inputs(node_id, network_path, &mut node_template)?;
10451045

10461046
let align_input = NodeInput::value(TaggedValue::StrokeAlign(StrokeAlign::Center), false);
@@ -1059,10 +1059,10 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
10591059
}
10601060

10611061
// Upgrade the old "Spline" node to the new "Spline" node
1062-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::vector::spline::IDENTIFIER)
1063-
|| reference == &DefinitionIdentifier::ProtoNode(ProtoNodeIdentifier::new("graphene_core::vector::generator_nodes::SplineNode"))
1064-
|| reference == &DefinitionIdentifier::ProtoNode(ProtoNodeIdentifier::new("graphene_core::vector::SplineNode"))
1065-
|| reference == &DefinitionIdentifier::ProtoNode(ProtoNodeIdentifier::new("graphene_core::vector::SplinesFromPointsNode"))
1062+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::spline::IDENTIFIER)
1063+
|| reference == DefinitionIdentifier::ProtoNode(ProtoNodeIdentifier::new("graphene_core::vector::generator_nodes::SplineNode"))
1064+
|| reference == DefinitionIdentifier::ProtoNode(ProtoNodeIdentifier::new("graphene_core::vector::SplineNode"))
1065+
|| reference == DefinitionIdentifier::ProtoNode(ProtoNodeIdentifier::new("graphene_core::vector::SplinesFromPointsNode"))
10661066
{
10671067
// Retrieve the proto node identifier and verify it is the old "Spline" node, otherwise skip it if this is the new "Spline" node
10681068
let identifier = document
@@ -1135,7 +1135,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
11351135
}
11361136

11371137
// Upgrade Text node to include line height and character spacing, which were previously hardcoded to 1, from https://github.com/GraphiteEditor/Graphite/pull/2016
1138-
if reference == &DefinitionIdentifier::Network("Text".to_string()) && inputs_count != 11 {
1138+
if reference == DefinitionIdentifier::Network("Text".to_string()) && inputs_count != 11 {
11391139
let mut template: NodeTemplate = resolve_document_node_type(&reference)?.default_node_template();
11401140
document.network_interface.replace_implementation(node_id, network_path, &mut template);
11411141
let old_inputs = document.network_interface.replace_inputs(node_id, network_path, &mut template)?;
@@ -1210,9 +1210,9 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
12101210
}
12111211

12121212
// 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
1213-
if (reference == &DefinitionIdentifier::ProtoNode(graphene_std::math_nodes::sine::IDENTIFIER)
1214-
|| reference == &DefinitionIdentifier::ProtoNode(graphene_std::math_nodes::cosine::IDENTIFIER)
1215-
|| reference == &DefinitionIdentifier::ProtoNode(graphene_std::math_nodes::tangent::IDENTIFIER))
1213+
if (reference == DefinitionIdentifier::ProtoNode(graphene_std::math_nodes::sine::IDENTIFIER)
1214+
|| reference == DefinitionIdentifier::ProtoNode(graphene_std::math_nodes::cosine::IDENTIFIER)
1215+
|| reference == DefinitionIdentifier::ProtoNode(graphene_std::math_nodes::tangent::IDENTIFIER))
12161216
&& inputs_count == 1
12171217
{
12181218
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
@@ -1227,7 +1227,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
12271227
}
12281228

12291229
// Upgrade the 'Tangent on Path' node 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
1230-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::vector::tangent_on_path::IDENTIFIER) && inputs_count == 4 {
1230+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::tangent_on_path::IDENTIFIER) && inputs_count == 4 {
12311231
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
12321232
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
12331233

@@ -1243,7 +1243,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
12431243
}
12441244

12451245
// Upgrade the Modulo node to include a boolean input for whether the output should be always positive, which was previously not an option
1246-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::math_nodes::modulo::IDENTIFIER) && inputs_count == 2 {
1246+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::math_nodes::modulo::IDENTIFIER) && inputs_count == 2 {
12471247
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
12481248
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
12491249

@@ -1257,7 +1257,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
12571257
}
12581258

12591259
// Upgrade the Mirror node to add the `keep_original` boolean input
1260-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::vector::mirror::IDENTIFIER) && inputs_count == 3 {
1260+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::mirror::IDENTIFIER) && inputs_count == 3 {
12611261
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
12621262
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
12631263

@@ -1272,7 +1272,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
12721272
}
12731273

12741274
// Upgrade the Mirror node to add the `reference_point` input and change `offset` from `DVec2` to `f64`
1275-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::vector::mirror::IDENTIFIER) && inputs_count == 4 {
1275+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::mirror::IDENTIFIER) && inputs_count == 4 {
12761276
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
12771277
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
12781278

@@ -1295,22 +1295,22 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
12951295
}
12961296

12971297
// Upgrade artboard name being passed as hidden value input to "Create Artboard"
1298-
if reference == &DefinitionIdentifier::Network("Artboard".to_string()) && reset_node_definitions_on_open {
1298+
if reference == DefinitionIdentifier::Network("Artboard".to_string()) && reset_node_definitions_on_open {
12991299
let label = document.network_interface.display_name(node_id, network_path);
13001300
document
13011301
.network_interface
13021302
.set_input(&InputConnector::node(NodeId(0), 1), NodeInput::value(TaggedValue::String(label), false), &[*node_id]);
13031303
}
13041304

1305-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::raster_nodes::std_nodes::image_value::IDENTIFIER) && inputs_count == 1 {
1305+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::raster_nodes::std_nodes::image_value::IDENTIFIER) && inputs_count == 1 {
13061306
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
13071307
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
13081308

13091309
// Insert a new empty input for the image
13101310
document.network_interface.add_import(TaggedValue::None, false, 0, "Empty", "", &[*node_id]);
13111311
}
13121312

1313-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::raster_nodes::std_nodes::noise_pattern::IDENTIFIER) && inputs_count == 15 {
1313+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::raster_nodes::std_nodes::noise_pattern::IDENTIFIER) && inputs_count == 15 {
13141314
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
13151315
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
13161316

@@ -1324,7 +1324,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
13241324
}
13251325
}
13261326

1327-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::vector::instance_on_points::IDENTIFIER) && inputs_count == 2 {
1327+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::instance_on_points::IDENTIFIER) && inputs_count == 2 {
13281328
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
13291329
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
13301330

@@ -1334,7 +1334,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
13341334
document.network_interface.set_input(&InputConnector::node(*node_id, 1), old_inputs[1].clone(), network_path);
13351335
}
13361336

1337-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::vector::instance_on_points::IDENTIFIER) && inputs_count == 4 {
1337+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::instance_on_points::IDENTIFIER) && inputs_count == 4 {
13381338
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
13391339
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
13401340

@@ -1346,7 +1346,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
13461346
// We have removed the last input, so we don't add index 3
13471347
}
13481348

1349-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::brush::brush::brush::IDENTIFIER) && inputs_count == 4 {
1349+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::brush::brush::brush::IDENTIFIER) && inputs_count == 4 {
13501350
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
13511351
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
13521352

@@ -1358,7 +1358,22 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
13581358
document.network_interface.set_input(&InputConnector::node(*node_id, 2), old_inputs[3].clone(), network_path);
13591359
}
13601360

1361-
if reference == &DefinitionIdentifier::ProtoNode(ProtoNodeIdentifier::new("graphene_core::vector::GenerateHandlesNode")) {
1361+
if reference == DefinitionIdentifier::ProtoNode(ProtoNodeIdentifier::new("graphene_core::vector::RemoveHandlesNode")) {
1362+
let mut node_template = resolve_document_node_type(&DefinitionIdentifier::ProtoNode(graphene_std::vector::auto_tangents::IDENTIFIER))?.default_node_template();
1363+
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
1364+
1365+
let old_inputs = document.network_interface.replace_inputs(node_id, network_path, &mut node_template)?;
1366+
1367+
document.network_interface.set_input(&InputConnector::node(*node_id, 0), old_inputs[0].clone(), network_path);
1368+
document
1369+
.network_interface
1370+
.set_input(&InputConnector::node(*node_id, 1), NodeInput::value(TaggedValue::F64(0.), false), network_path);
1371+
document
1372+
.network_interface
1373+
.set_input(&InputConnector::node(*node_id, 2), NodeInput::value(TaggedValue::Bool(false), false), network_path);
1374+
}
1375+
1376+
if reference == DefinitionIdentifier::ProtoNode(ProtoNodeIdentifier::new("graphene_core::vector::GenerateHandlesNode")) {
13621377
let mut node_template = resolve_document_node_type(&DefinitionIdentifier::ProtoNode(graphene_std::vector::auto_tangents::IDENTIFIER))?.default_node_template();
13631378
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
13641379

@@ -1371,7 +1386,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
13711386
.set_input(&InputConnector::node(*node_id, 2), NodeInput::value(TaggedValue::Bool(true), false), network_path);
13721387
}
13731388

1374-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::vector::merge_by_distance::IDENTIFIER) && inputs_count == 2 {
1389+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::merge_by_distance::IDENTIFIER) && inputs_count == 2 {
13751390
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
13761391
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
13771392

@@ -1386,7 +1401,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
13861401
);
13871402
}
13881403

1389-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::vector::merge_by_distance::IDENTIFIER) {
1404+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::merge_by_distance::IDENTIFIER) {
13901405
let mut node_template = resolve_document_node_type(&DefinitionIdentifier::ProtoNode(graphene_std::vector::merge_by_distance::IDENTIFIER))?.default_node_template();
13911406
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
13921407

@@ -1401,7 +1416,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
14011416
);
14021417
}
14031418

1404-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::vector::sample_polyline::IDENTIFIER) && inputs_count == 5 {
1419+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::sample_polyline::IDENTIFIER) && inputs_count == 5 {
14051420
let mut node_template = resolve_document_node_type(&DefinitionIdentifier::ProtoNode(graphene_std::vector::sample_polyline::IDENTIFIER))?.default_node_template();
14061421
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
14071422

@@ -1421,7 +1436,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
14211436
}
14221437

14231438
// Make the "Quantity" parameter a u32 instead of f64
1424-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::vector::sample_polyline::IDENTIFIER) {
1439+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::sample_polyline::IDENTIFIER) {
14251440
// Get the inputs, obtain the quantity value, and put the inputs back
14261441
let quantity_value = document
14271442
.network_interface
@@ -1436,7 +1451,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
14361451
}
14371452

14381453
// Make the "Grid" node, if its input of index 3 is a DVec2 for "angles" instead of a u32 for the "columns" input that now succeeds "angles", move the angle to index 5 (after "columns" and "rows")
1439-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::vector::generator_nodes::grid::IDENTIFIER) && inputs_count == 6 {
1454+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::generator_nodes::grid::IDENTIFIER) && inputs_count == 6 {
14401455
let node_definition = resolve_document_node_type(&reference)?;
14411456
let mut new_node_template = node_definition.default_node_template();
14421457

@@ -1466,7 +1481,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
14661481
}
14671482

14681483
// Add the "Depth" parameter to the "Instance Index" node
1469-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::vector::instance_index::IDENTIFIER) && inputs_count == 0 {
1484+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::instance_index::IDENTIFIER) && inputs_count == 0 {
14701485
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
14711486
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
14721487
document.network_interface.set_display_name(node_id, "Instance Index".to_string(), network_path);
@@ -1479,7 +1494,7 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
14791494
}
14801495

14811496
// Migrate the Transform node to use degrees instead of radians
1482-
if reference == &DefinitionIdentifier::Network("Transform".to_string()) && node.inputs.get(6).is_none() {
1497+
if reference == DefinitionIdentifier::Network("Transform".to_string()) && node.inputs.get(6).is_none() {
14831498
let mut node_template = resolve_document_node_type(&DefinitionIdentifier::Network("Transform".to_string()))?.default_node_template();
14841499
document.network_interface.replace_implementation(node_id, network_path, &mut node_template);
14851500

@@ -1556,14 +1571,14 @@ fn migrate_node(node_id: &NodeId, node: &DocumentNode, network_path: &[NodeId],
15561571
// The old version would zip the source and target table rows, interpoleating each pair together.
15571572
// The migrated version will instead deeply flatten both merged tables and morph sequentially between all source vectors and all target vector elements.
15581573
// This migration assumes most usages didn't involve multiple parallel vector elements, and instead morphed from a single source to a single target vector element.
1559-
if reference == &DefinitionIdentifier::ProtoNode(graphene_std::vector::morph::IDENTIFIER) && inputs_count == 3 {
1574+
if reference == DefinitionIdentifier::ProtoNode(graphene_std::vector::morph::IDENTIFIER) && inputs_count == 3 {
15601575
// Old signature:
15611576
// async fn morph(_: impl Ctx, source: Table<Vector>, #[expose] target: Table<Vector>, #[default(0.5)] time: Fraction) -> Table<Vector> { ... }
15621577
//
15631578
// New signature:
15641579
// async fn morph<I: IntoGraphicTable>(_: impl Ctx, content: #[implementations(Table<Graphic>, Table<Vector>)] content: I, progression: Progression) -> Table<Vector> { ... }
15651580

1566-
let mut node_template = resolve_document_node_type(reference)?.default_node_template();
1581+
let mut node_template = resolve_document_node_type(&reference)?.default_node_template();
15671582
let old_inputs = document.network_interface.replace_inputs(node_id, network_path, &mut node_template)?;
15681583

15691584
// Create a new Merge node

frontend/wasm/src/editor_api.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::{EDITOR_HANDLE, EDITOR_HAS_CRASHED, Error, MESSAGE_BUFFER};
99
use editor::consts::FILE_EXTENSION;
1010
use editor::messages::input_mapper::utility_types::input_keyboard::ModifierKeys;
1111
use editor::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, ScrollDelta};
12-
use editor::messages::portfolio::document::node_graph::document_node_definitions::DefinitionIdentifier;
1312
use editor::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
1413
use editor::messages::portfolio::document::utility_types::network_interface::ImportOrExport;
1514
use editor::messages::portfolio::utility_types::Platform;

0 commit comments

Comments
 (0)