Skip to content
Snippets Groups Projects
Unverified Commit c0c20c07 authored by Nathan Wilson's avatar Nathan Wilson Committed by GitHub
Browse files

Check for an error in querying for a window before trying to find sca… (#161)

* Check for an error in querying for a window before trying to find scale factor.

* Use method that returns Result rather than method that panics.
parent 3126966e
No related branches found
No related tags found
No related merge requests found
...@@ -210,11 +210,13 @@ pub fn set_initial_scale( ...@@ -210,11 +210,13 @@ pub fn set_initial_scale(
mut cosmic_query: Query<&mut CosmicBuffer, Added<CosmicBuffer>>, mut cosmic_query: Query<&mut CosmicBuffer, Added<CosmicBuffer>>,
mut font_system: ResMut<CosmicFontSystem>, mut font_system: ResMut<CosmicFontSystem>,
) { ) {
let w_scale = window_q.single().scale_factor(); if let Ok(window) = window_q.get_single() {
let w_scale = window.scale_factor();
for mut b in &mut cosmic_query.iter_mut() { for mut b in &mut cosmic_query.iter_mut() {
let m = b.metrics().scale(w_scale); let m = b.metrics().scale(w_scale);
b.set_metrics(&mut font_system, m); b.set_metrics(&mut font_system, m);
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment