Skip to content

Detach reattach propagation fix#24019

Merged
alice-i-cecile merged 2 commits intobevyengine:mainfrom
ickshonpe:detatch-reattach-propagation-fix
Apr 28, 2026
Merged

Detach reattach propagation fix#24019
alice-i-cecile merged 2 commits intobevyengine:mainfrom
ickshonpe:detatch-reattach-propagation-fix

Conversation

@ickshonpe
Copy link
Copy Markdown
Contributor

@ickshonpe ickshonpe commented Apr 28, 2026

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

@ickshonpe ickshonpe added A-ECS Entities, components, systems, and events S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 28, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in ECS Apr 28, 2026
@ickshonpe ickshonpe added the C-Bug An unexpected or incorrect behavior label Apr 28, 2026
@ickshonpe ickshonpe added this to the 0.19 milestone Apr 28, 2026
@ickshonpe ickshonpe changed the title Detatch reattach propagation fix Detach reattach propagation fix Apr 28, 2026
@alice-i-cecile alice-i-cecile added D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 28, 2026
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Apr 28, 2026
Merged via the queue into bevyengine:main with commit c3dab1a Apr 28, 2026
49 checks passed
@github-project-automation github-project-automation Bot moved this from Needs SME Triage to Done in ECS Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

UI: detach_children + insert_children in the same system leaves the re-parented subtree invisible

2 participants