From 3838956bb8989cf00709b2746adf74e661146329 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Mon, 19 Apr 2021 16:37:24 +0100 Subject: [PATCH] JAL-3833 cap the scaling used by HiDPISetting for incorrect DPI values or incorrect height/width values --- src/jalview/bin/HiDPISetting.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/jalview/bin/HiDPISetting.java b/src/jalview/bin/HiDPISetting.java index 497900f..ab5735d 100644 --- a/src/jalview/bin/HiDPISetting.java +++ b/src/jalview/bin/HiDPISetting.java @@ -35,6 +35,8 @@ public class HiDPISetting public static int scale = 0; + public final static int MAX_SCALE = 8; + private static boolean doneInit = false; private static boolean allowScalePropertyArg = false; @@ -147,6 +149,14 @@ public class HiDPISetting int dimensionScale = 1 + (mindimension / bigScreenThreshold); + // reject outrageous values -- dpiScale in particular could be mistaken + if (dpiScale > MAX_SCALE) { + dpiScale = 1; + } + if (dimensionScale > MAX_SCALE) { + dimensionScale = 1; + } + // choose larger of dimensionScale or dpiScale (most likely dimensionScale // as dpiScale often misreported) int autoScale = Math.max(dpiScale, dimensionScale); -- 1.7.10.2