[Bugfix] add_stage now checks Stage existence#1346
Merged
Conversation
bjorn3
reviewed
Jan 29, 2021
bjorn3 suggested this change to improve startup time Co-authored-by: bjorn3 <[email protected]>
Contributor
Author
|
As @cart elaborated in the resolved conversation, panicking is the way to go for now. Error-handling being a discussion to be held in a different issue. @bjorn3 's changes have been merged and additionally been applied to |
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.
What's the bug?
add_stagenever checked whether a givenStage-name already exists (which extends towith_stage())bevy/crates/bevy_ecs/src/schedule/mod.rs
Lines 59 to 63 in cc9ed52
instead simply
StageinSchedule.stages(effectively removing all systems/schedulers/... attached to that old Stage)Schedule.stage_order, while not removing the already existing one, creating a duplicateHow is it fixed?
This has been fixed using the same method the other two functions
add_stage_afterandadd_stage_beforeuse:This also raises the question:
Stage-name is already taken, or should some sort of Error-flow be implemented to allow handling it?Why does it matter?
Since this bug effectively changed system-execution, it could have caused some interesting and hard to debug problems.
Especially later on, when other Stages are added in relation to this one.
add_stageis supposed to place a Stage at the end of execution-order at the time of calling (Vec::push()). Thus anything added via e.g.add_stage_before(this_broken_stage)would be expected to execute as e.g. second-last. Howeveradd_stage_beforedetermines positioning via:This would return the index of the duplicate in
Schedule.stage_orderat the old position, earlier in the execution-order.