if (!widthChanged && !wrapped && d->singleline && !scaleFont)
goto geomChangeDone; // only height has changed which doesn't affect single line unwrapped text
- if (!widthChanged && wrapped && d->elideMode != QQuickText::ElideRight && !scaleFont)
+ if (!widthChanged && wrapped && d->elideMode != QQuickText::ElideRight && !scaleFont && !d->isLineLaidOutConnected())
goto geomChangeDone; // only height changed and no multiline eliding.
if (leftAligned && d->elideMode == QQuickText::ElideRight && !d->truncated && d->singleline
--- /dev/null
+import QtQuick 2.0
+
+Rectangle {
+ id: main
+ width: 320
+ height: 418
+
+ property int yOffset: 0
+
+ Component.onCompleted: myText.height = height
+
+ Text {
+ id: myText
+ objectName: "myText"
+ width: parent.width
+ height: 0
+ wrapMode: Text.WordWrap
+ font.pointSize: 14
+ focus: true
+
+ text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+Integer at ante dui Curabitur ante est, pulvinar quis adipiscing a, iaculis id ipsum. Nunc blandit
+condimentum odio vel egestas. in ipsum lacinia sit amet
+mattis orci interdum. Quisque vitae accumsan lectus. Ut nisi turpis,
+sollicitudin ut dignissim id, fermentum ac est. Maecenas nec libero leo. Sed ac
+mattis orci interdum. Quisque vitae accumsan lectus. Ut nisi turpis,
+sollicitudin ut dignissim id, fermentum ac est. Maecenas nec libero leo. Sed ac
+leo eget ipsum ultricies viverra sit amet eu orci. Praesent et tortor risus,
+viverra accumsan sapien. Sed faucibus eleifend lectus, sed euismod urna porta
+eu. Quisque vitae accumsan lectus."
+
+ onLineLaidOut: {
+ line.width = width / 2
+
+ if (line.y + line.height >= height) {
+ if (main.yOffset === 0)
+ main.yOffset = line.y
+ line.y -= main.yOffset
+ line.x = width / 2
+ } else {
+ main.yOffset = 0
+ }
+ }
+ }
+}
void boundingRect();
void clipRect();
void lineLaidOut();
+ void lineLaidOutRelayout();
void imgTagsBaseUrl_data();
void imgTagsBaseUrl();
delete canvas;
}
+void tst_qquicktext::lineLaidOutRelayout()
+{
+ QQuickView *canvas = createView(testFile("lineLayoutRelayout.qml"));
+
+ canvas->show();
+ canvas->requestActivateWindow();
+ QTest::qWaitForWindowShown(canvas);
+
+ QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != 0);
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
+ QVERIFY(textPrivate != 0);
+
+ QVERIFY(!textPrivate->extra.isAllocated());
+
+#if defined(Q_OS_MAC)
+ QVERIFY(myText->lineCount() == textPrivate->linesRects.count());
+#endif
+
+ qreal maxH = 0;
+ for (int i = 0; i < textPrivate->layout.lineCount(); ++i) {
+ QRectF r = textPrivate->layout.lineAt(i).rect();
+
+ if (r.x() == 0) {
+ QCOMPARE(r.y(), i * r.height());
+ maxH = qMax(maxH, r.y() + r.height());
+ } else {
+ QCOMPARE(r.x(), myText->width() / 2);
+ QCOMPARE(r.y(), (i * r.height()) - maxH);
+ }
+ }
+
+ delete canvas;
+}
+
void tst_qquicktext::imgTagsBaseUrl_data()
{
QTest::addColumn<QUrl>("src");