mirror of
https://github.com/eliasstepanik/egui_node_graph.git
synced 2026-01-21 02:38:26 +00:00
return disconnect responses before removal response
This allows for a more logical order of cleanup operations in user code. Disconnect and clean up the node before removal.
This commit is contained in:
parent
4db5eea1ab
commit
0747ab595d
@ -242,17 +242,19 @@ where
|
|||||||
}
|
}
|
||||||
NodeResponse::DeleteNodeUi(node_id) => {
|
NodeResponse::DeleteNodeUi(node_id) => {
|
||||||
let (node, disc_events) = self.graph.remove_node(*node_id);
|
let (node, disc_events) = self.graph.remove_node(*node_id);
|
||||||
|
// Pass the disconnection responses first so user code can perform cleanup
|
||||||
|
// before node removal response.
|
||||||
|
extra_responses.extend(
|
||||||
|
disc_events
|
||||||
|
.into_iter()
|
||||||
|
.map(|(input, output)| NodeResponse::DisconnectEvent { input, output }),
|
||||||
|
);
|
||||||
// Pass the full node as a response so library users can
|
// Pass the full node as a response so library users can
|
||||||
// listen for it and get their user data.
|
// listen for it and get their user data.
|
||||||
extra_responses.push(NodeResponse::DeleteNodeFull {
|
extra_responses.push(NodeResponse::DeleteNodeFull {
|
||||||
node_id: *node_id,
|
node_id: *node_id,
|
||||||
node,
|
node,
|
||||||
});
|
});
|
||||||
extra_responses.extend(
|
|
||||||
disc_events
|
|
||||||
.into_iter()
|
|
||||||
.map(|(input, output)| NodeResponse::DisconnectEvent { input, output }),
|
|
||||||
);
|
|
||||||
self.node_positions.remove(*node_id);
|
self.node_positions.remove(*node_id);
|
||||||
// Make sure to not leave references to old nodes hanging
|
// Make sure to not leave references to old nodes hanging
|
||||||
if self.selected_node.map(|x| x == *node_id).unwrap_or(false) {
|
if self.selected_node.map(|x| x == *node_id).unwrap_or(false) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user