diff --git a/egui_node_graph_example/src/app.rs b/egui_node_graph_example/src/app.rs index ac60aba..9c1fb76 100644 --- a/egui_node_graph_example/src/app.rs +++ b/egui_node_graph_example/src/app.rs @@ -376,17 +376,21 @@ impl epi::App for NodeGraphExample { } if let Some(node) = self.state.user_state.active_node { - let text = match evaluate_node(&self.state.graph, node, &mut HashMap::new()) { - Ok(value) => format!("The result is: {:?}", value), - Err(err) => format!("Execution error: {}", err), - }; - ctx.debug_painter().text( - egui::pos2(10.0, 10.0), - egui::Align2::LEFT_TOP, - text, - egui::TextStyle::Button, - egui::Color32::WHITE, - ); + if self.state.graph.nodes.contains_key(node) { + let text = match evaluate_node(&self.state.graph, node, &mut HashMap::new()) { + Ok(value) => format!("The result is: {:?}", value), + Err(err) => format!("Execution error: {}", err), + }; + ctx.debug_painter().text( + egui::pos2(10.0, 10.0), + egui::Align2::LEFT_TOP, + text, + egui::TextStyle::Button, + egui::Color32::WHITE, + ); + } else { + self.state.user_state.active_node = None; + } } } }