From 7d68ac029eb8ffe428b3d6d3ce5236cfafec6a86 Mon Sep 17 00:00:00 2001 From: Chris Russell <8494645+chescock@users.noreply.github.com> Date: Wed, 29 Jan 2025 23:50:17 -0500 Subject: [PATCH] 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()`. --- crates/bevy_ecs/src/world/entity_ref.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/bevy_ecs/src/world/entity_ref.rs b/crates/bevy_ecs/src/world/entity_ref.rs index b8146fa86a313..912f4a968606f 100644 --- a/crates/bevy_ecs/src/world/entity_ref.rs +++ b/crates/bevy_ecs/src/world/entity_ref.rs @@ -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, ); }