From 9d7e85f6cfb11cba318575ae3e0c90d4a6b1a525 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Thu, 23 Jan 2025 10:51:55 +0100 Subject: [PATCH] Remove some unwraps --- crates/eframe/src/web/events.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/eframe/src/web/events.rs b/crates/eframe/src/web/events.rs index 9c6156bbfb3..93d4e456635 100644 --- a/crates/eframe/src/web/events.rs +++ b/crates/eframe/src/web/events.rs @@ -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();