From a6015a326bbb02cc07c07aff085d3cfcb52adfa4 Mon Sep 17 00:00:00 2001 From: "@clasher113" Date: Sat, 29 Mar 2025 21:53:05 +0200 Subject: [PATCH] fix: image render & LabelCache::update crash --- src/graphics/ui/elements/Label.cpp | 2 +- src/graphics/ui/elements/UINode.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/graphics/ui/elements/Label.cpp b/src/graphics/ui/elements/Label.cpp index fd8ac725..3339f307 100644 --- a/src/graphics/ui/elements/Label.cpp +++ b/src/graphics/ui/elements/Label.cpp @@ -51,7 +51,7 @@ void LabelCache::update(std::wstring_view text, bool multiline, bool wrap) { if (text[i] == L'\n') { lines.push_back(LineScheme {i+1, false}); len = 0; - } else if (i > 0 && wrap && text[i+1] != L'\n') { + } else if (i > 0 && i+1 < text.length() && wrap && text[i+1] != L'\n') { size_t width = font->calcWidth(text, i-len-1, i-(i-len)+2); if (width >= wrapWidth) { // starting a fake line diff --git a/src/graphics/ui/elements/UINode.cpp b/src/graphics/ui/elements/UINode.cpp index d975315a..08316e32 100644 --- a/src/graphics/ui/elements/UINode.cpp +++ b/src/graphics/ui/elements/UINode.cpp @@ -160,9 +160,9 @@ CursorShape UINode::getCursor() const { glm::vec2 UINode::calcPos() const { if (parent) { - return pos + parent->calcPos() + parent->getContentOffset(); + return glm::ivec2(pos + parent->calcPos() + parent->getContentOffset()); } - return pos; + return glm::ivec2(pos); } void UINode::scrolled(int value) {