aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quick/items/qquicktext.cpp5
-rw-r--r--tests/auto/quick/qquicktext/data/elideZeroWidth.qml23
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp10
3 files changed, 37 insertions, 1 deletions
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 0546f80fd5..399f2009fd 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -2429,7 +2429,10 @@ void QQuickText::geometryChange(const QRectF &newGeometry, const QRectF &oldGeom
}
}
} else if (!heightChanged && widthMaximum) {
- goto geomChangeDone;
+ if (!qFuzzyIsNull(oldGeometry.width())) {
+ // no change to height, width is adequate and wasn't 0 before
+ goto geomChangeDone;
+ }
}
if (d->updateOnComponentComplete || d->textHasChanged) {
diff --git a/tests/auto/quick/qquicktext/data/elideZeroWidth.qml b/tests/auto/quick/qquicktext/data/elideZeroWidth.qml
new file mode 100644
index 0000000000..1193909350
--- /dev/null
+++ b/tests/auto/quick/qquicktext/data/elideZeroWidth.qml
@@ -0,0 +1,23 @@
+import QtQuick 2.15
+
+Item {
+ id: root
+ property bool ok: false
+ width: 640
+ height: 480
+
+ Text {
+ id: text
+ text: "This is a quite long text. Click me and i should remain visible!!! Sadly this doesn't happen"
+ elide: Text.ElideRight
+ }
+
+ Component.onCompleted: {
+ text.width = 300;
+ text.height = 0;
+ text.width = 0;
+ text.height = 30;
+ text.width = 300;
+ root.ok = text.paintedWidth > 0 && text.paintedHeight > 0
+ }
+}
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index d1716c20da..572a30bafc 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -68,6 +68,7 @@ private slots:
void wrap();
void elide();
void elideParentChanged();
+ void elideRelayoutAfterZeroWidth();
void multilineElide_data();
void multilineElide();
void implicitElide_data();
@@ -607,6 +608,15 @@ void tst_qquicktext::elideParentChanged()
QCOMPARE(actualItemImageGrab, expectedItemImageGrab);
}
+void tst_qquicktext::elideRelayoutAfterZeroWidth()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("elideZeroWidth.qml"));
+ QScopedPointer<QObject> root(component.create());
+ QVERIFY2(root, qPrintable(component.errorString()));
+ QVERIFY(root->property("ok").toBool());
+}
+
void tst_qquicktext::multilineElide_data()
{
QTest::addColumn<QQuickText::TextFormat>("format");