Skip to content

Commit

Permalink
Runners explicitly call App.initialize() (bevyengine#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
smokku authored and joshuajbouw committed Oct 24, 2020
1 parent d02fd38 commit 8d6fdf5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl App {
.run(&mut self.schedule, &mut self.world, &mut self.resources);
}

pub fn run(mut self) {
pub fn initialize(&mut self) {
self.startup_schedule
.initialize(&mut self.world, &mut self.resources);
self.startup_executor.initialize(&mut self.resources);
Expand All @@ -72,7 +72,9 @@ impl App {
&mut self.world,
&mut self.resources,
);
}

pub fn run(mut self) {
self.executor.initialize(&mut self.resources);
let runner = std::mem::replace(&mut self.runner, Box::new(run_once));
(runner)(self);
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_app/src/schedule_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ impl Plugin for ScheduleRunnerPlugin {
fn build(&self, app: &mut AppBuilder) {
let run_mode = self.run_mode;
app.set_runner(move |mut app: App| {
app.initialize();

let mut app_exit_event_reader = EventReader::<AppExit>::default();
match run_mode {
RunMode::Once => {
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ pub fn winit_runner(mut app: App) {
&mut create_window_event_reader,
);

app.initialize();

log::debug!("Entering winit event loop");

let should_return_from_run = app
Expand Down

0 comments on commit 8d6fdf5

Please sign in to comment.