Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix example return_after_run #1082

Merged
merged 4 commits into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/bevy_log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ impl Plugin for LogPlugin {
app.resources_mut().insert_thread_local(guard);
let subscriber = subscriber.with(chrome_layer);
bevy_utils::tracing::subscriber::set_global_default(subscriber)
.expect("Could not set global default tracing subscriber.");
.expect("Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins");
}

#[cfg(not(feature = "tracing-chrome"))]
{
bevy_utils::tracing::subscriber::set_global_default(subscriber)
.expect("Could not set global default tracing subscriber.");
.expect("Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins");
}
}

Expand All @@ -91,14 +91,14 @@ impl Plugin for LogPlugin {
tracing_wasm::WASMLayerConfig::default(),
));
bevy_utils::tracing::subscriber::set_global_default(subscriber)
.expect("Could not set global default tracing subscriber.");
.expect("Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins");
}

#[cfg(target_os = "android")]
{
let subscriber = subscriber.with(android_tracing::AndroidLayer::default());
bevy_utils::tracing::subscriber::set_global_default(subscriber)
.expect("Could not set global default tracing subscriber.");
.expect("Could not set global default tracing subscriber. If you've already set up a tracing subscriber, please disable LogPlugin from Bevy's DefaultPlugins");
}
}
}
18 changes: 13 additions & 5 deletions crates/bevy_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,19 @@ pub fn winit_runner(mut app: App) {
let mut focused_events =
app.resources.get_mut::<Events<WindowFocused>>().unwrap();
let winit_windows = app.resources.get_mut::<WinitWindows>().unwrap();
let window_id = winit_windows.get_window_id(winit_window_id).unwrap();
focused_events.send(WindowFocused {
id: window_id,
focused,
});
match (winit_windows.get_window_id(winit_window_id), focused) {
(Some(window_id), _) => focused_events.send(WindowFocused {
id: window_id,
focused,
}),
// unfocus event for an unknown window, ignore it
(None, false) => (),
// focus event on an unknown window, this is an error
_ => panic!(
"Focused(true) event on unknown window {:?}",
winit_window_id
),
}
}
_ => {}
},
Expand Down
14 changes: 13 additions & 1 deletion examples/app/return_after_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,26 @@ fn main() {
})
.add_resource(ClearColor(Color::rgb(0.2, 0.2, 0.8)))
.add_plugins(DefaultPlugins)
.add_system(system1.system())
.run();
println!("Running another App.");
App::build()
.add_resource(WinitConfig {
return_from_run: true,
})
.add_resource(ClearColor(Color::rgb(0.2, 0.8, 0.2)))
.add_plugins(DefaultPlugins)
.add_plugins_with(DefaultPlugins, |group| {
group.disable::<bevy::log::LogPlugin>()
})
.add_system(system2.system())
.run();
println!("Done.");
}

fn system1() {
info!("logging from first app");
}

fn system2() {
info!("logging from second app");
}