Skip to content

Commit

Permalink
Use the provided caller instead of Location::caller() in `despawn…
Browse files Browse the repository at this point in the history
…_with_caller()` (#17598)

# Objective

Pass the correct location to triggers when despawning entities.
`EntityWorldMut::despawn_with_caller()` currently passes
`Location::caller()` to some triggers instead of the `caller` parameter
it was passed. As `despawn_with_caller()` is not `#[track_caller]`, this
means the location will always be reported as `despawn_with_caller()`
itself.

## Solution

Pass `caller` instead of `Location::caller()`.
  • Loading branch information
chescock authored Jan 30, 2025
1 parent 2c9950f commit 7d68ac0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/bevy_ecs/src/world/entity_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2289,31 +2289,31 @@ impl<'w> EntityWorldMut<'w> {
self.entity,
archetype.components(),
#[cfg(feature = "track_location")]
Location::caller(),
caller,
);
}
deferred_world.trigger_on_replace(
archetype,
self.entity,
archetype.components(),
#[cfg(feature = "track_location")]
Location::caller(),
caller,
);
if archetype.has_remove_observer() {
deferred_world.trigger_observers(
ON_REMOVE,
self.entity,
archetype.components(),
#[cfg(feature = "track_location")]
Location::caller(),
caller,
);
}
deferred_world.trigger_on_remove(
archetype,
self.entity,
archetype.components(),
#[cfg(feature = "track_location")]
Location::caller(),
caller,
);
}

Expand Down

0 comments on commit 7d68ac0

Please sign in to comment.