From c81c242c5a371c4e3845d93eb4df674ae179fe5f Mon Sep 17 00:00:00 2001 From: PeterN Date: Thu, 17 Nov 2022 09:10:47 +0000 Subject: [PATCH] Fix: Crash if error message window is too wide for screen. (#10172) This doesn't seem new, just easier to trigger with new scaling. --- src/error_gui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/error_gui.cpp b/src/error_gui.cpp index d54d0a2705..77a96bfc7d 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -245,8 +245,8 @@ public: pt.y = UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top; pt.y = (pt.y < (_screen.height >> 1)) ? scr_bot - sm_height : scr_top; } else { - pt.x = Clamp(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (sm_width / 2), 0, _screen.width - sm_width); - pt.y = Clamp(UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top - (sm_height / 2), scr_top, scr_bot - sm_height); + pt.x = std::min(std::max(UnScaleByZoom(pt.x - vp->virtual_left, vp->zoom) + vp->left - (sm_width / 2), 0), _screen.width - sm_width); + pt.y = std::min(std::max(UnScaleByZoom(pt.y - vp->virtual_top, vp->zoom) + vp->top - (sm_height / 2), scr_top), scr_bot - sm_height); } return pt; }