Skip to content

Commit

Permalink
Remove some unwraps
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Jan 23, 2025
1 parent ac5c32d commit 2cdc3a7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions crates/eframe/src/web/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,14 @@ fn install_dpr_change_event(web_runner: &WebRunner) -> Result<(), JsValue> {
let original_dpr = native_pixels_per_point();

let window = web_sys::window().unwrap();
let media_query_list = window
.match_media(&format!("(resolution: {original_dpr}dppx)"))
.unwrap()
.unwrap();
let Some(media_query_list) =
window.match_media(&format!("(resolution: {original_dpr}dppx)"))?
else {
log::error!(
"Failed to create MediaQueryList: eframe won't be able to detect changes in DPR"
);
return Ok(());
};

let closure = move |_: web_sys::Event, app_runner: &mut AppRunner, web_runner: &WebRunner| {
let new_dpr = native_pixels_per_point();
Expand Down

0 comments on commit 2cdc3a7

Please sign in to comment.