Use the provided caller instead of Location::caller() in despawn_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()`.
This commit is contained in:
Chris Russell 2025-01-29 23:50:17 -05:00 committed by GitHub
parent 2c9950fcf8
commit 7d68ac029e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2289,7 +2289,7 @@ impl<'w> EntityWorldMut<'w> {
self.entity,
archetype.components(),
#[cfg(feature = "track_location")]
Location::caller(),
caller,
);
}
deferred_world.trigger_on_replace(
@ -2297,7 +2297,7 @@ impl<'w> EntityWorldMut<'w> {
self.entity,
archetype.components(),
#[cfg(feature = "track_location")]
Location::caller(),
caller,
);
if archetype.has_remove_observer() {
deferred_world.trigger_observers(
@ -2305,7 +2305,7 @@ impl<'w> EntityWorldMut<'w> {
self.entity,
archetype.components(),
#[cfg(feature = "track_location")]
Location::caller(),
caller,
);
}
deferred_world.trigger_on_remove(
@ -2313,7 +2313,7 @@ impl<'w> EntityWorldMut<'w> {
self.entity,
archetype.components(),
#[cfg(feature = "track_location")]
Location::caller(),
caller,
);
}