Ticket #666 (new defect)

Opened 2 years ago

Last modified 16 months ago

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

Change History

comment:1 Changed 2 years ago by totycro@…

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.

comment:2 Changed 2 years ago by prock

  • Component changed from engine/core/gui to engine/extensions/pychan
  • Milestone changed from Proposal to 0.3.4

Moving to 0.3.4 for consideration.

comment:3 Changed 16 months ago by prock

  • Milestone changed from 0.3.4 to 0.3.5

Moving to 0.3.5 as we are preparing to release 0.3.4

Note: See TracTickets for help on using tickets.