From 79cfc8788d6267eeb263983466ba21758f618dcd Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 12 May 2016 14:56:20 +0200 Subject: Fix incorrectly aligned text whose size depends on its implicit size The if statement in QQuickTextPrivate::setupTextLayout() was missing an OR clause for the case where the line width is neither greater nor less than the old width/natural width, but has actually changed. If that sounds confusing, it's because it is. Basically, the outer layouting loop in that function needs to run twice for this scenario, so that's what this patch makes it do. Change-Id: I13777667eb13506d50f05e9766785a1c2c46125c Task-number: QTBUG-50738 Task-number: QTBUG-50740 Reviewed-by: Liang Qi --- src/quick/items/qquicktext.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/quick/items/qquicktext.cpp') diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 044e6ce8c1..ee5965676c 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -882,11 +882,11 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline) // If the width of the item has changed and it's possible the result of wrapping, // eliding, scaling has changed, or the text is not left aligned do another layout. - if ((lineWidth < qMin(oldWidth, naturalWidth) || (widthExceeded && lineWidth > oldWidth)) + if ((!qFuzzyCompare(lineWidth, oldWidth) || (widthExceeded && lineWidth > oldWidth)) && (singlelineElide || multilineElide || canWrap || horizontalFit || q->effectiveHAlign() != QQuickText::AlignLeft)) { widthChanged = true; - widthExceeded = false; + widthExceeded = lineWidth >= qMin(oldWidth, naturalWidth); heightExceeded = false; continue; } -- cgit v1.2.3