mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 07:48:12 +08:00
Fix node insertion crash caused by mismatched DefinitionIdentifier serialization (#4353)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
use crate::messages::input_mapper::utility_types::input_keyboard::KeysGroup;
|
use crate::messages::input_mapper::utility_types::input_keyboard::KeysGroup;
|
||||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||||
|
use crate::messages::portfolio::document::node_graph::document_node_definitions::DefinitionIdentifier;
|
||||||
use crate::messages::prelude::*;
|
use crate::messages::prelude::*;
|
||||||
use graphene_std::color::SRGBA8;
|
use graphene_std::color::SRGBA8;
|
||||||
use graphene_std::vector::style::FillChoiceUI;
|
use graphene_std::vector::style::FillChoiceUI;
|
||||||
@@ -291,7 +292,11 @@ impl LayoutMessageHandler {
|
|||||||
responses.add(callback_message);
|
responses.add(callback_message);
|
||||||
}
|
}
|
||||||
WidgetValueAction::Update => {
|
WidgetValueAction::Update => {
|
||||||
let callback_message = (node_type_input.on_update.callback)(&value.into());
|
let Value::String(ref node_type) = value else {
|
||||||
|
error!("NodeCatalog update was not of type: String, found {value:?}");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let callback_message = (node_type_input.on_update.callback)(&DefinitionIdentifier::from_serialized(node_type));
|
||||||
responses.add(callback_message);
|
responses.add(callback_message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ use graphene_std::raster_types::{CPU, Raster};
|
|||||||
use graphene_std::transform::Footprint;
|
use graphene_std::transform::Footprint;
|
||||||
use graphene_std::vector::Vector;
|
use graphene_std::vector::Vector;
|
||||||
use graphene_std::*;
|
use graphene_std::*;
|
||||||
use serde_json::Value;
|
|
||||||
use std::collections::{HashMap, VecDeque};
|
use std::collections::{HashMap, VecDeque};
|
||||||
|
|
||||||
pub struct NodePropertiesContext<'a> {
|
pub struct NodePropertiesContext<'a> {
|
||||||
@@ -89,12 +88,8 @@ impl DefinitionIdentifier {
|
|||||||
DefinitionIdentifier::Network(data) => format!("NETWORK:{}", data),
|
DefinitionIdentifier::Network(data) => format!("NETWORK:{}", data),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Value> for DefinitionIdentifier {
|
|
||||||
fn from(value: Value) -> Self {
|
|
||||||
let s = value.as_str().expect("DefinitionIdentifier value must be a string");
|
|
||||||
|
|
||||||
|
pub fn from_serialized(s: &str) -> Self {
|
||||||
match s.split_once(':') {
|
match s.split_once(':') {
|
||||||
Some(("PROTONODE", data)) => DefinitionIdentifier::ProtoNode(ProtoNodeIdentifier::with_owned_string(data.to_string())),
|
Some(("PROTONODE", data)) => DefinitionIdentifier::ProtoNode(ProtoNodeIdentifier::with_owned_string(data.to_string())),
|
||||||
Some(("NETWORK", data)) => DefinitionIdentifier::Network(data.to_string()),
|
Some(("NETWORK", data)) => DefinitionIdentifier::Network(data.to_string()),
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ mod editor_commands {
|
|||||||
use editor::messages::clipboard::utility_types::ClipboardContentRaw;
|
use editor::messages::clipboard::utility_types::ClipboardContentRaw;
|
||||||
use editor::messages::input_mapper::utility_types::input_keyboard::ModifierKeys;
|
use editor::messages::input_mapper::utility_types::input_keyboard::ModifierKeys;
|
||||||
use editor::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, ScrollDelta};
|
use editor::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, ScrollDelta};
|
||||||
|
use editor::messages::portfolio::document::node_graph::document_node_definitions::DefinitionIdentifier;
|
||||||
use editor::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
|
use editor::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
|
||||||
use editor::messages::portfolio::document::utility_types::network_interface::ImportOrExport;
|
use editor::messages::portfolio::document::utility_types::network_interface::ImportOrExport;
|
||||||
use editor::messages::portfolio::utility_types::PanelGroupId;
|
use editor::messages::portfolio::utility_types::PanelGroupId;
|
||||||
@@ -515,11 +516,11 @@ mod editor_commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new document node in the node graph
|
/// Creates a new document node in the node graph
|
||||||
fn create_node(node_type: Any, x: i32, y: i32) -> Message {
|
fn create_node(node_type: String, x: i32, y: i32) -> Message {
|
||||||
let id = NodeId::new();
|
let id = NodeId::new();
|
||||||
NodeGraphMessage::CreateNodeFromContextMenu {
|
NodeGraphMessage::CreateNodeFromContextMenu {
|
||||||
node_id: Some(id),
|
node_id: Some(id),
|
||||||
node_type: node_type.cast(),
|
node_type: DefinitionIdentifier::from_serialized(&node_type),
|
||||||
xy: Some((x / 24, y / 24)),
|
xy: Some((x / 24, y / 24)),
|
||||||
add_transaction: true,
|
add_transaction: true,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user