Fix hang on missing state update handler#1051
Merged
cart merged 1 commit intobevyengine:masterfrom Dec 13, 2020
Merged
Conversation
e05bd97 to
64dca14
Compare
Member
|
Ooh very nice catch. I think we can make this a bit simpler by just adding a break in the event that we don't have a "next" and "update" isn't set: if let Some(next_stage) = next_stage {
if next_stage != current_stage {
if let Some(exit_current) = self
.stages
.get_mut(¤t_stage)
.and_then(|stage| stage.exit.as_mut())
{
exit_current.run(world, resources);
}
}
if let Some(enter_next) = self
.stages
.get_mut(&next_stage)
.and_then(|stage| stage.enter.as_mut())
{
enter_next.run(world, resources);
}
} else if let Some(update_current) = self
.stages
.get_mut(¤t_stage)
.and_then(|stage| stage.update.as_mut())
{
update_current.run(world, resources);
break;
} else {
break;
} |
Contributor
Author
|
I thought this way it would show the flow more clearly: First it loops until it finds the current stage, then it calls "update" edit: The commit before my force-push (e05bd97) looked more like your version |
Member
|
Thats a fair point. At a glance you can tell that "update" only runs once. I'm sold! |
Closed
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.
If a state's "update" stage is None, then the state
runloop is infinite, so this fixes it.