From d24313e236e20298ead09334dbd8627d8dfee86d Mon Sep 17 00:00:00 2001 From: corfe83 <61067263+corfe83@users.noreply.github.com> Date: Tue, 20 Apr 2021 19:43:23 -0700 Subject: [PATCH] internal/devicescale: Fallback to simpler logic when trying to get DPI from monitor and failing (#1600) Closes #1612 --- internal/devicescale/impl_windows.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/devicescale/impl_windows.go b/internal/devicescale/impl_windows.go index 1b59f4a3b..6fda040d8 100644 --- a/internal/devicescale/impl_windows.go +++ b/internal/devicescale/impl_windows.go @@ -240,13 +240,15 @@ func impl(x, y int) float64 { // do this with Cgo. Use MonitorFromRect instead. m, err := monitorFromRect(&lprc, monitorDefaultToNearest) if err != nil { - panic(err) + // monitorFromRect can fail in some environments (#1612) + return getFromLogPixelSx() } dpiX := uint32(0) dpiY := uint32(0) // Passing dpiY is needed even though this is not used, or GetDpiForMonitor returns an error. if err := getDpiForMonitor(m, mdtEffectiveDpi, &dpiX, &dpiY); err != nil { - panic(err) + // getDpiForMonitor can fail in some environments (#1612) + return getFromLogPixelSx() } runtime.KeepAlive(dpiY)