Commit c3dab1a
authored
Detach reattach propagation fix (#24019)
# Objective
Fixes #23893
Chain of events as far as I can follow it:
1. Remove a relationship from an entity E.
2. Immediately restore the relationship.
3. The `on_r_removed<C, R>` observer system triggered by `On<Remove, R>`
removes the `Inherited<C>` component from E.
4. The `on_r_inserted<C, R>` observer system triggered by `On<Insert,
R>` inserts `Inherited<C>` back again on E.
5. `propagated_inherited` queries for changes, adds `(E, Inherited<C>)`
to `to_process`.
6. `propagate_inherited` queries for `RemovedComponents<Inherited<C>>`,
adds `(F, None)` to `to_process` for each F descended from E.
7. Then `to_process` is processed.
8. The `(F, None)` entries are processed first, recursively removing
`Inherited<C>` from E's descendants using deferred commands.
9. Then `(E, Inherited<C>)` is ignored as the defererred commands
haven't been applied yet so the current inherited state matches the
queued inherited state.
## Solution
If an entity from `RemovedComponents<Inherited<C>>` has `Inherited<C>`,
don't add its descendants to the `to_process` stack.
Not super confident in this change, but the new test passes and none of
the old tests fail.
## Testing
New test: `test_detach_and_reattach_propagates_to_descendants`1 parent 5754300 commit c3dab1a
1 file changed
Lines changed: 40 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
266 | | - | |
| 266 | + | |
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| |||
479 | 479 | | |
480 | 480 | | |
481 | 481 | | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
482 | 521 | | |
483 | 522 | | |
484 | 523 | | |
| |||
0 commit comments