Closed kkngsm closed 2 years ago
Sorry.
It was self.state.user_state.active_node
, not MyResponse::SetActiveNode(node)
, that was holding NodeId
.
And, I should reset self.state.user_state.active_node
,
To be exact
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()) {
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;
+ }
}
This is a great library 😍. Thank you!
I will report it because
egui_node_graph_example
crashed.Operation until the crash
Reason for the bug
This is because
MyResponse::SetActiveNode(node)
holds theNodeId
even if the node is deleted, and uses thatNodeId
to access the deleted Node in theevaluate_node
function.How to fix
https://github.com/setzer22/egui_node_graph/blob/8408503866201ee5db4af72ab19494278942afbd/egui_node_graph_example/src/app.rs#L378-L390