Skip to content

Commit

Permalink
Fix hang on missing state update handler (bevyengine#1051)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapir authored Dec 13, 2020
1 parent 9a4327b commit 002e22f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions crates/bevy_ecs/src/schedule/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl<T: Resource + Clone> Stage for StateStage<T> {
}

fn run(&mut self, world: &mut World, resources: &mut Resources) {
loop {
let current_stage = loop {
let (next_stage, current_stage) = {
let mut state = resources
.get_mut::<State<T>>()
Expand Down Expand Up @@ -132,14 +132,17 @@ impl<T: Resource + Clone> Stage for StateStage<T> {
{
enter_next.run(world, resources);
}
} else if let Some(update_current) = self
.stages
.get_mut(&current_stage)
.and_then(|stage| stage.update.as_mut())
{
update_current.run(world, resources);
break;
} else {
break current_stage;
}
};

if let Some(update_current) = self
.stages
.get_mut(&current_stage)
.and_then(|stage| stage.update.as_mut())
{
update_current.run(world, resources);
}
}
}
Expand Down

0 comments on commit 002e22f

Please sign in to comment.