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

update_old_parent Doesn't check to see if parent actually exists. #8337

Closed
StarArawn opened this issue Apr 9, 2023 · 2 comments · Fixed by #8346
Closed

update_old_parent Doesn't check to see if parent actually exists. #8337

StarArawn opened this issue Apr 9, 2023 · 2 comments · Fixed by #8346
Labels
A-Hierarchy Parent-child entity hierarchies C-Bug An unexpected or incorrect behavior P-Crash A sudden unexpected crash

Comments

@StarArawn
Copy link
Contributor

Bevy version

0.10.1

What you did

I have a setup like this:

- parent 1
  - child 1

What went wrong

I have a change like this:

1. Spawn parent 2
2. despawn parent 1
3. add child 1 as a child of parent 2

And I get this error:
thread 'main' panicked at 'Entity 43v0 does not exist'

Additional information

It looks like we just need to check if the parent exists.

@StarArawn StarArawn added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Apr 9, 2023
@StarArawn
Copy link
Contributor Author

Here is a reproducible example:

use bevy::prelude::*;

fn main() {
    App::new()
    .add_plugins(DefaultPlugins)
    .add_startup_system(bug)
    .run();
}

fn bug(world: &mut World) {
    let parent_0 = world.spawn_empty().id();
    let child_0 = world.spawn_empty().id();

    world.entity_mut(parent_0).add_child(child_0);

    world.entity_mut(parent_0).despawn();

    let parent_1 = world.spawn_empty().id();
    world.entity_mut(parent_1).add_child(child_0);
}

@alice-i-cecile alice-i-cecile added P-Crash A sudden unexpected crash A-Hierarchy Parent-child entity hierarchies and removed S-Needs-Triage This issue needs to be labelled labels Apr 9, 2023
@alice-i-cecile
Copy link
Member

I agree that this is a bug: this shouldn't crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Hierarchy Parent-child entity hierarchies C-Bug An unexpected or incorrect behavior P-Crash A sudden unexpected crash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants