Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
bevy_ecs: flush entities after running observers and hooks in despawn #15398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bevy_ecs: flush entities after running observers and hooks in despawn #15398
Changes from all commits
313c896
0669dd1
12c5e3e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also a call to
world.flush_entities();
at the top of this method. Do we need both, or did that one just need to get moved down here?It looks like prior to #10756 the
flush()
call was right before thefree()
call, and the hooks and observers code got added in between. The calls todeferred_world.trigger_on_foo
inbundle.rs
don't haveflush()
calls. That makes me think that we don't need to flush before triggering things, and we only need the single call here, right before thefree()
.It doesn't look like anything bad can happen if we flush twice, though, so it should be fine to leave both even if they're not both needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, so if I remove the first
world.flush_entities()
, the tests all pass and everything appears to work fine. As long as observers and hooks are unable to call any methods onEntities
thatverify_flushed()
, it's safe to move. Since all of those require mutable access toEntities
and thus exclusiveWorld
access as far as I'm aware, we should be OK to remove the first one.