From 35b294611c74a1c23573966bc12f7c859ad16764 Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Fri, 24 Oct 2025 01:14:37 +0200 Subject: [PATCH] fix regression of #6235 --- client/windows/GUIClasses.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/client/windows/GUIClasses.cpp b/client/windows/GUIClasses.cpp index ee565990a..660569035 100644 --- a/client/windows/GUIClasses.cpp +++ b/client/windows/GUIClasses.cpp @@ -1671,11 +1671,24 @@ void CObjectListWindow::trimTextIfTooWide(std::string & text) const int maxWidth = pos.w - 60; // 60 px for scrollbar and borders auto posBrace = text.find('('); auto posClosing = text.find(')'); - std::string objCount = text.substr(posBrace, posClosing - posBrace) + ')'; - if(text[0] == '{') - objCount = '}' + objCount; + + std::string objCount; + if (posBrace != std::string::npos && posClosing != std::string::npos && posClosing > posBrace) + { + objCount = text.substr(posBrace, posClosing - posBrace) + ')'; + if(text.size() > 0 && text[0] == '{') + objCount = '}' + objCount; + } + else + { + // fallback: if text starts with '{', keep a trailing '}' token, otherwise empty + if(text.size() > 0 && text[0] == '{') + objCount = "}"; + else + objCount.clear(); + } const auto & font = ENGINE->renderHandler().loadFont(FONT_SMALL); - std::string suffix = "... " + objCount; + std::string suffix = objCount.empty() ? "..." : std::string("... ") + objCount; if(font->getStringWidth(text) >= maxWidth) {