Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use try_insert instead of insert in bevy_ui to prevent panics when despawning ui nodes #13000

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/bevy_ui/src/accessibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn button_changed(
}
commands
.entity(entity)
.insert(AccessibilityNode::from(node));
.try_insert(AccessibilityNode::from(node));
}
}
}
Expand Down Expand Up @@ -107,7 +107,7 @@ fn image_changed(
}
commands
.entity(entity)
.insert(AccessibilityNode::from(node));
.try_insert(AccessibilityNode::from(node));
}
}
}
Expand Down Expand Up @@ -137,7 +137,7 @@ fn label_changed(
}
commands
.entity(entity)
.insert(AccessibilityNode::from(node));
.try_insert(AccessibilityNode::from(node));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ui/src/texture_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ pub(crate) fn compute_slices_on_asset_event(
atlas,
&atlas_layouts,
) {
commands.entity(entity).insert(slices);
commands.entity(entity).try_insert(slices);
}
}
}
Expand Down Expand Up @@ -213,7 +213,7 @@ pub(crate) fn compute_slices_on_image_change(
atlas,
&atlas_layouts,
) {
commands.entity(entity).insert(slices);
commands.entity(entity).try_insert(slices);
}
}
}
4 changes: 2 additions & 2 deletions crates/bevy_ui/src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn update_clipping(
}
} else if let Some(inherited_clip) = maybe_inherited_clip {
// No previous calculated clip, add a new CalculatedClip component with the inherited clipping rect
commands.entity(entity).insert(CalculatedClip {
commands.entity(entity).try_insert(CalculatedClip {
clip: inherited_clip,
});
}
Expand Down Expand Up @@ -163,7 +163,7 @@ fn update_children_target_camera(

match camera_to_set {
Some(camera) => {
commands.entity(child).insert(camera.clone());
commands.entity(child).try_insert(camera.clone());
}
None => {
commands.entity(child).remove::<TargetCamera>();
Expand Down