diff --git a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs index 0f8d65e7..c23284b2 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs @@ -345,7 +345,8 @@ impl NodeGraphMessageHandler { }); let primary_output = outputs.next(); - let thumbnail_svg = executor.thumbnails.get(&layer_id).and_then(|thumbnails| thumbnails.get(id)).map(|svg| svg.to_string()); + let graph_identifier = GraphIdentifier::new(layer_id); + let thumbnail_svg = executor.thumbnails.get(&graph_identifier).and_then(|thumbnails| thumbnails.get(id)).map(|svg| svg.to_string()); nodes.push(FrontendNode { id: *id, diff --git a/editor/src/node_graph_executor.rs b/editor/src/node_graph_executor.rs index fbea2041..b9149863 100644 --- a/editor/src/node_graph_executor.rs +++ b/editor/src/node_graph_executor.rs @@ -52,7 +52,7 @@ pub struct NodeRuntime { sender: InternalNodeGraphUpdateSender, wasm_io: Option, imaginate_preferences: ImaginatePreferences, - pub(crate) thumbnails: HashMap, HashMap>, + pub(crate) thumbnails: HashMap>, canvas_cache: HashMap, SurfaceId>, } @@ -73,7 +73,7 @@ pub(crate) struct GenerationResponse { generation_id: u64, result: Result, updates: VecDeque, - new_thumbnails: HashMap, HashMap>, + new_thumbnails: HashMap>, } enum NodeGraphUpdate { @@ -224,7 +224,8 @@ impl NodeRuntime { render.format_svg(min, max); if let Some(node_id) = node_path.get(node_path.len() - 2).copied() { - let old_thumbnail = self.thumbnails.entry(layer_path.last().copied()).or_default().entry(node_id).or_default(); + let graph_identifier = GraphIdentifier::new(layer_path.last().copied()); + let old_thumbnail = self.thumbnails.entry(graph_identifier).or_default().entry(node_id).or_default(); if *old_thumbnail != render.svg { *old_thumbnail = render.svg; thumbnails_changed = true; @@ -278,7 +279,7 @@ pub struct NodeGraphExecutor { receiver: Receiver, // TODO: This is a memory leak since layers are never removed pub(crate) last_output_type: HashMap, Option>, - pub(crate) thumbnails: HashMap, HashMap>, + pub(crate) thumbnails: HashMap>, futures: HashMap, } @@ -528,7 +529,7 @@ impl NodeGraphExecutor { /// When a blob url for a thumbnail is loaded, update the state and the UI. pub fn insert_thumbnail_blob_url(&mut self, blob_url: String, layer_id: Option, node_id: NodeId, responses: &mut VecDeque) { - if let Some(layer) = self.thumbnails.get_mut(&layer_id) { + if let Some(layer) = self.thumbnails.get_mut(&GraphIdentifier::new(layer_id)) { if let Some(segment) = layer.values_mut().flat_map(|segments| segments.iter_mut()).find(|segment| **segment == SvgSegment::BlobUrl(node_id)) { *segment = SvgSegment::String(blob_url); responses.add(NodeGraphMessage::SendGraph { should_rerender: false });