Skip to content

Commit

Permalink
bevy_render: Make the remove_node method fallible and proxy errors up
Browse files Browse the repository at this point in the history
  • Loading branch information
superdump committed Mar 20, 2022
1 parent b56343f commit 7933c05
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions crates/bevy_render/src/render_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ impl RenderGraph {

/// Removes the `node` with the `name` from the graph.
/// If the name is does not exist, nothing happens.
pub fn remove_node(&mut self, name: impl Into<Cow<'static, str>>) {
pub fn remove_node(
&mut self,
name: impl Into<Cow<'static, str>>,
) -> Result<(), RenderGraphError> {
let name = name.into();
if let Some(id) = self.node_names.remove(&name) {
if let Some(node_state) = self.nodes.remove(&id) {
Expand All @@ -118,21 +121,15 @@ impl RenderGraph {
input_index: _,
} => {
if let Ok(output_node) = self.get_node_state_mut(*output_node) {
output_node
.edges
.remove_output_edge(input_edge.clone())
.ok();
output_node.edges.remove_output_edge(input_edge.clone())?;
}
}
Edge::NodeEdge {
input_node: _,
output_node,
} => {
if let Ok(output_node) = self.get_node_state_mut(*output_node) {
output_node
.edges
.remove_output_edge(input_edge.clone())
.ok();
output_node.edges.remove_output_edge(input_edge.clone())?;
}
}
}
Expand All @@ -148,21 +145,23 @@ impl RenderGraph {
input_index: _,
} => {
if let Ok(input_node) = self.get_node_state_mut(*input_node) {
input_node.edges.remove_input_edge(output_edge.clone()).ok();
input_node.edges.remove_input_edge(output_edge.clone())?;
}
}
Edge::NodeEdge {
output_node: _,
input_node,
} => {
if let Ok(input_node) = self.get_node_state_mut(*input_node) {
input_node.edges.remove_input_edge(output_edge.clone()).ok();
input_node.edges.remove_input_edge(output_edge.clone())?;
}
}
}
}
}
}

Ok(())
}

/// Retrieves the [`NodeState`] referenced by the `label`.
Expand Down

0 comments on commit 7933c05

Please sign in to comment.