Small addition to World::flush_commands explaining how spawn will cause it to panic.#15411
Merged
alice-i-cecile merged 2 commits intobevyengine:mainfrom Sep 30, 2024
Merged
Conversation
Contributor
|
Is there a situation where you would want to call |
Contributor
Author
|
I was wondering that when I noticed |
BenjaminBrienen
suggested changes
Sep 25, 2024
BenjaminBrienen
approved these changes
Sep 25, 2024
pablo-lua
approved these changes
Sep 25, 2024
robtfm
pushed a commit
to robtfm/bevy
that referenced
this pull request
Oct 4, 2024
… cause it to panic. (bevyengine#15411) # Objective `World::flush_commands` will cause a panic with `error[B0003]: Could not insert a bundle [...] for entity [...] because it doesn't exist in this World` if there was a `spawn` command in the queue and you should instead use `flush` for this but this isn't mentioned in the docs ## Solution Add a note to the docs suggesting to use `World::flush` in this context. This error doesn't appear to happen with `spawn_batch` so I didn't add that to the note although you can cause it with `commands.spawn_empty().insert(...)` but I wasn't sure that was worth the documentation complexity as it is pretty unlikely (and equivalent to `commands.spawn(...)`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Objective
World::flush_commandswill cause a panic witherror[B0003]: Could not insert a bundle [...] for entity [...] because it doesn't exist in this Worldif there was aspawncommand in the queue and you should instead useflushfor this but this isn't mentioned in the docsSolution
Add a note to the docs suggesting to use
World::flushin this context. This error doesn't appear to happen withspawn_batchso I didn't add that to the note although you can cause it withcommands.spawn_empty().insert(...)but I wasn't sure that was worth the documentation complexity as it is pretty unlikely (and equivalent tocommands.spawn(...).