diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2018-04-09 14:05:53 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2018-04-17 10:30:18 +0000 |
commit | 56ade46b4234bb828b8e4f9a6bf83b5687bd122e (patch) | |
tree | b2834ac9af2564280df343be9db702689c596278 /src/quick | |
parent | 0b394e30bba4f6bb7e6f7dbe5585a2e15aa0f21d (diff) |
Fix Text with ElideRight not being rendered when reparented
Consider the following example:
Item {
width: 100
height: 30
Text {
width: parent ? parent.width : 0
height: parent ? parent.height : 0
elide: Text.ElideRight
text: "wot"
}
}
When setting the Text item's parent to null, its explicit width and
height are set to 0. When restoring its parent (the Item), its
explicit width and height are set to 100 and 30 again, but the text
itself is still not rendered.
The cause can be seen here:
if (!(widthChanged || widthMaximum) && !d->isLineLaidOutConnected()) {
// only height has changed
if (newGeometry.height() > oldGeometry.height()) {
if (!d->heightExceeded) // Height is adequate and growing.
goto geomChangeDone;
heightExceeded was false, because 30 > 12 (or whatever the implicit
height happened to be), so the text was not laid out again, even though
it went from having an explicit height of 0 to an explicit height of
30.
Fix the issue by only executing the goto if the old explicit height
wasn't 0.
Task-number: QTBUG-60328
Task-number: QTBUG-67145
Change-Id: I7f4d2f95bc95c850133ba91ac2d1a02c7ee159b6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/quick')
-rw-r--r-- | src/quick/items/qquicktext.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 383aa2b821..9eaf9f8d6d 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -2318,8 +2318,10 @@ void QQuickText::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeo if (!(widthChanged || widthMaximum) && !d->isLineLaidOutConnected()) { // only height has changed if (newGeometry.height() > oldGeometry.height()) { - if (!d->heightExceeded) // Height is adequate and growing. + if (!d->heightExceeded && !qFuzzyIsNull(oldGeometry.height())) { + // Height is adequate and growing, and it wasn't 0 previously. goto geomChangeDone; + } if (d->lineCount == d->maximumLineCount()) // Reached maximum line and height is growing. goto geomChangeDone; } else if (newGeometry.height() < oldGeometry.height()) { |