Commit ce57258
Fix observers' access to relationship data during
# Objective
- Fix issue where observers cannot access relationship data during
`despawn_related`
- Fixes #20106
## Solution
- Changed `despawn_related` to use `get()` instead of `take()` to
preserve relationship components during the despawn process
- Collect entities into a vector before despawning to ensure the
relationship data remains accessible to observers and hooks
## Testing
- Added test `despawn_related_observers_can_access_relationship_data`
that reproduces the issue scenario
---------
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>despawn_related (#20258)1 parent ba73f66 commit ce57258
File tree
1 file changed
+43
-3
lines changed- crates/bevy_ecs/src/relationship
1 file changed
+43
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
303 | 306 | | |
304 | | - | |
| 307 | + | |
305 | 308 | | |
306 | 309 | | |
307 | | - | |
| 310 | + | |
308 | 311 | | |
309 | 312 | | |
310 | 313 | | |
| |||
882 | 885 | | |
883 | 886 | | |
884 | 887 | | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
885 | 925 | | |
0 commit comments