summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2025-06-06 10:00:20 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2025-06-11 09:52:35 +0000
commit75ce4e40dc1e44c48647e618c2b129af0299a8fc (patch)
tree856a9baaecbc7bcb8f406b2f64a719130d814fb1
parent015675ecabdb4730073ade93f643b29929420f78 (diff)
downloadmana-75ce4e40dc1e44c48647e618c2b129af0299a8fc.tar.gz
mana-75ce4e40dc1e44c48647e618c2b129af0299a8fc.tar.bz2
mana-75ce4e40dc1e44c48647e618c2b129af0299a8fc.tar.xz
mana-75ce4e40dc1e44c48647e618c2b129af0299a8fc.zip
Fixed the maximum size of the ShortcutWindow
It should be at least the minimum size. This was not the case when there were no emotes provided by the server (as for Source of Tales currently). Issue manifested itself as `std::clamp` assert in debug builds, and probably undefined but harmless behavior in release builds.
-rw-r--r--src/gui/shortcutwindow.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp
index 2cffbb81..78a22335 100644
--- a/src/gui/shortcutwindow.cpp
+++ b/src/gui/shortcutwindow.cpp
@@ -49,8 +49,11 @@ ShortcutWindow::ShortcutWindow(const std::string &title,
const int border = (getPadding() + content->getFrameSize()) * 2;
setMinWidth(content->getBoxWidth() + border);
setMinHeight(content->getBoxHeight() + border + GRAB_MARGIN);
- setMaxWidth(content->getBoxWidth() * content->getMaxItems() + border);
- setMaxHeight(content->getBoxHeight() * content->getMaxItems() + border + GRAB_MARGIN);
+
+ const int maxContentWidth = content->getBoxWidth() * content->getMaxItems();
+ const int maxContentHeight = content->getBoxHeight() * content->getMaxItems();
+ setMaxWidth(std::max(getMinWidth(), maxContentWidth + border));
+ setMaxHeight(std::max(getMinHeight(), maxContentHeight + border + GRAB_MARGIN));
setDefaultSize(getMinWidth(), getMaxHeight(), ImageRect::LOWER_RIGHT);