Fix a crash bug when deleting an active node

This commit is contained in:
nekomehako 2022-05-11 01:56:34 +09:00
parent 8408503866
commit b81479cc88

View File

@ -376,6 +376,7 @@ impl epi::App for NodeGraphExample {
} }
if let Some(node) = self.state.user_state.active_node { if let Some(node) = self.state.user_state.active_node {
if self.state.graph.nodes.contains_key(node) {
let text = match evaluate_node(&self.state.graph, node, &mut HashMap::new()) { let text = match evaluate_node(&self.state.graph, node, &mut HashMap::new()) {
Ok(value) => format!("The result is: {:?}", value), Ok(value) => format!("The result is: {:?}", value),
Err(err) => format!("Execution error: {}", err), Err(err) => format!("Execution error: {}", err),
@ -387,6 +388,9 @@ impl epi::App for NodeGraphExample {
egui::TextStyle::Button, egui::TextStyle::Button,
egui::Color32::WHITE, egui::Color32::WHITE,
); );
} else {
self.state.user_state.active_node = None;
}
} }
} }
} }