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

[Merged by Bors] - Update EntityMut's location in push_children() and insert_children() #2604

Closed
wants to merge 3 commits into from

Conversation

Davier
Copy link
Contributor

@Davier Davier commented Aug 5, 2021

Objective

This code would result in a crash:

use bevy::prelude::*;

fn main() {
    let mut world = World::new();
    let child = world.spawn().id();
    world.spawn().push_children(&[child]);
}

Solution

Update the EntityMut's location after inserting a component on the children entities, as it may have changed.

@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Aug 5, 2021
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior and removed S-Needs-Triage This issue needs to be labelled labels Aug 5, 2021
@alice-i-cecile
Copy link
Member

Actually, could you add your previously crashing code as a regression test?

Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes I'd suggest are only for internal documentation, and otherwise this looks good.

crates/bevy_transform/src/hierarchy/child_builder.rs Outdated Show resolved Hide resolved
crates/bevy_transform/src/hierarchy/child_builder.rs Outdated Show resolved Hide resolved
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Aug 8, 2021
@cart
Copy link
Member

cart commented Aug 10, 2021

Thats a pretty nasty bug. Nice catch!

@cart
Copy link
Member

cart commented Aug 10, 2021

bors r+

bors bot pushed a commit that referenced this pull request Aug 10, 2021
…2604)

## Objective

This code would result in a crash:
```rust
use bevy::prelude::*;

fn main() {
    let mut world = World::new();
    let child = world.spawn().id();
    world.spawn().push_children(&[child]);
}
```

## Solution

Update the `EntityMut`'s location after inserting a component on the children entities, as it may have changed.
@bors bors bot changed the title Update EntityMut's location in push_children() and insert_children() [Merged by Bors] - Update EntityMut's location in push_children() and insert_children() Aug 10, 2021
@bors bors bot closed this Aug 10, 2021
@Davier Davier deleted the fix_push_children branch October 19, 2021 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants