Skip to content

Commit b32026c

Browse files
committed
bevy_ecs: flush entities after running observers and hooks in despawn
1 parent ec2e512 commit b32026c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

crates/bevy_ecs/src/world/entity_ref.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,10 @@ impl<'w> EntityWorldMut<'w> {
13191319
}
13201320
}
13211321

1322+
// Observers and on_remove hooks may reserve new entities, which
1323+
// requires a flush before Entities::free may be called.
1324+
world.flush_entities();
1325+
13221326
for component_id in archetype.components() {
13231327
world.removed_components.send(component_id, self.entity);
13241328
}

0 commit comments

Comments
 (0)