From e497f0e78dd9770a3fd833f748deb6860182064d Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 14 Jul 2022 23:21:23 +0100 Subject: [PATCH] Fix crash in tooltip window UpdateWidgetSize due to not using saved string --- src/misc_gui.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 5f957449ea..668057c69f 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -768,10 +768,15 @@ struct TooltipsWindow : public Window void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { /* There is only one widget. */ - for (uint i = 0; i != this->paramcount; i++) SetDParam(i, this->params[i]); + if (this->paramcount == 0) { + size->width = std::min(GetStringBoundingBox(this->buffer).width, ScaleGUITrad(194)); + size->height = GetStringHeight(this->buffer, size->width); + } else { + for (uint i = 0; i != this->paramcount; i++) SetDParam(i, this->params[i]); - size->width = std::min(GetStringBoundingBox(this->string_id).width, ScaleGUITrad(194)); - size->height = GetStringHeight(this->string_id, size->width); + size->width = std::min(GetStringBoundingBox(this->string_id).width, ScaleGUITrad(194)); + size->height = GetStringHeight(this->string_id, size->width); + } /* Increase slightly to have some space around the box. */ size->width += 2 + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;