Skip to content

Commit 0669dd1

Browse files
committed
bevy_ecs: flush entities after running observers and hooks in despawn
1 parent 313c896 commit 0669dd1

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
@@ -1323,6 +1323,10 @@ impl<'w> EntityWorldMut<'w> {
13231323
world.removed_components.send(component_id, self.entity);
13241324
}
13251325

1326+
// Observers and on_remove hooks may reserve new entities, which
1327+
// requires a flush before Entities::free may be called.
1328+
world.flush_entities();
1329+
13261330
let location = world
13271331
.entities
13281332
.free(self.entity)

0 commit comments

Comments
 (0)