Ticket #666 (new defect)
adjustSize() sometimes sets width to invalid values
| Reported by: | totycro@… | Owned by: | FIFE |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.3.5 |
| Component: | engine/extensions/pychan | Version: | trunk |
| Severity: | major | Keywords: | |
| Cc: | Blocked By: | ||
| Blocking: | Time planned: | ||
| Time remaining: | Time spent: |
Description
The setup is as follows:
A Label with a min and max width, which are the same. It gets some wrapped text, on resizeToContent, ClickLabel::adjustSize is called[1] (. Here, setWidth() is called with the result of mGuiFont->getAsImageMultiline(mWrappedText), which isFontBase::getAsImageMultiline [2]. This calculates a width of the text, which i don't yet know what it is.
However this width is set, violating the min/max constraints (first bug). The text is then rewrapped using wrapText() in setWidth(). After that, the height is set, but with the value from the original image, which has been calculated with the old width. Sometimes the rewrapping requires a new line, which would increase the height, but still the old value is set without rechecking. Therefore the last wrapped part is hidden (second bug).
So the width should not be changed in the first place in this case, and if it would be set in other cases, the height should adapt accordingly, or, the image returned by getAsImageMultiline should be such that it's wide enough to fit the maximum line of the original render, such that it decreases the width only so far that the height can stay the same (no additional newlines are introduced).
[1] engine/core/gui/guichan/widgets/clicklabel.cpp [2] engine/core/video/fonts/fontbase.cpp

A part of the issue might also be that min/max dimensions only exist in python. Here, setWidth is called in c++ internally, which bypasses setWidth from widget.py. This also means that all other c++ calls to setWidth are potentially harmful.