From 617bef73eed32d4d672f59c45afe193aa3f3aecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 21 Nov 2024 14:53:45 +0100 Subject: [PATCH] Fix a runtime warning in text rendering --- Common/UI/Context.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Common/UI/Context.cpp b/Common/UI/Context.cpp index 7e0574c4af..6fcbd38649 100644 --- a/Common/UI/Context.cpp +++ b/Common/UI/Context.cpp @@ -297,6 +297,10 @@ float UIContext::CalculateTextScale(std::string_view str, float availWidth, floa } void UIContext::DrawTextRectSqueeze(std::string_view str, const Bounds &bounds, uint32_t color, int align) { + if (bounds.w <= 0 || bounds.h <= 0) { + // Probably mid-layout. + return; + } float origScaleX = fontScaleX_; float origScaleY = fontScaleY_; float scale = CalculateTextScale(str, bounds.w / origScaleX, bounds.h / origScaleY);