Runners explicitly call App.initialize() (#690)

This commit is contained in:
Tomasz Sterna 2020-10-18 21:25:33 +02:00 committed by GitHub
parent a80469bd13
commit 149c39950a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View file

@ -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);
@ -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);

View file

@ -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 => {

View file

@ -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