Skip to content

Commit

Permalink
Don't Panic (#651)
Browse files Browse the repository at this point in the history
Don't panic when despawning recursively
  • Loading branch information
CleanCut authored Oct 9, 2020
1 parent bf501b7 commit 333fd3f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
- This allows drop-in use of colors from most applications.
- New methods `Color::rgb_linear` and `Color::rgba_linear` will accept colors already in linear sRGB (the old behavior)
- Individual color-components must now be accessed through setters and getters: `.r`, `.g`, `.b`, `.a`, `.set_r`, `.set_g`, `.set_b`, `.set_a`, and the corresponding methods with the `*_linear` suffix.
- Despawning an entity multiple times causes a debug-level log message to be emitted instead of a panic [649]
- Despawning an entity multiple times causes a debug-level log message to be emitted instead of a panic [649] [651]


[552]: https://github.com/bevyengine/bevy/pull/552
[616]: https://github.com/bevyengine/bevy/pull/616
[649]: https://github.com/bevyengine/bevy/pull/649
[651]: https://github.com/bevyengine/bevy/pull/651


## Version 0.2.1 (2020-9-20)

Expand Down
5 changes: 4 additions & 1 deletion crates/bevy_transform/src/hierarchy/hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ fn despawn_with_children_recursive_inner(world: &mut World, entity: Entity) {
}
}

world.despawn(entity).unwrap();
if let Err(e) = world.despawn(entity) {
log::debug!("Failed to despawn entity {:?}: {}", entity, e);
}
}

impl WorldWriter for DespawnRecursive {
Expand Down Expand Up @@ -128,6 +130,7 @@ mod tests {
let parent_entity = world.get::<Children>(grandparent_entity).unwrap()[0];

command_buffer.despawn_recursive(parent_entity);
command_buffer.despawn_recursive(parent_entity); // despawning the same entity twice should not panic
command_buffer.apply(&mut world, &mut resources);

let results = world
Expand Down

0 comments on commit 333fd3f

Please sign in to comment.