From 040d3f5d8b0f56e2cbd89e98d7cb4b0b0f83f6d1 Mon Sep 17 00:00:00 2001 From: Francesca Frangipane Date: Thu, 5 Jul 2018 11:52:25 -0400 Subject: [PATCH] Remove incorrect unreachable usage when guessing DPI factor (#592) --- CHANGELOG.md | 1 + src/platform/linux/x11/window.rs | 2 +- src/platform/windows/window.rs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f02f2e1..946fe8ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Unreleased - On Windows, non-resizable windows now have the maximization button disabled. This is consistent with behavior on macOS and popular X11 WMs. +- Corrected incorrect `unreachable!` usage when guessing the DPI factor with no detected monitors. # Version 0.16.1 (2018-07-02) diff --git a/src/platform/linux/x11/window.rs b/src/platform/linux/x11/window.rs index e7c01e9d..66394676 100644 --- a/src/platform/linux/x11/window.rs +++ b/src/platform/linux/x11/window.rs @@ -102,7 +102,7 @@ impl UnownedWindow { .unwrap_or(1.0) }) } else { - unreachable!("There are no detected monitors, which should've already caused a panic."); + return Err(OsError(format!("No monitors were detected."))); }; info!("Guessed window DPI factor: {}", dpi_factor); diff --git a/src/platform/windows/window.rs b/src/platform/windows/window.rs index f257c165..0d7227d9 100644 --- a/src/platform/windows/window.rs +++ b/src/platform/windows/window.rs @@ -872,7 +872,7 @@ unsafe fn init( } dpi_factor } else { - unreachable!("There are no detected monitors, which should've already caused a panic."); + return Err(CreationError::OsError(format!("No monitors were detected."))); }; dpi_factor.unwrap_or_else(|| { util::get_cursor_pos()