aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-01-14 09:21:14 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-01-14 13:52:16 +0000
commitc24757f1b642102852beb1f62c83bfd76ca31567 (patch)
tree2ccd7215992f290e09d9685d5b308be0699ace52 /tests/auto
parentd4adc833bfd1438f0e9c43e155a12a1cb63c4069 (diff)
Fix Text with ElideRight not being rendered when width goes from 0 to >0
QQuickText attempts to reduce relayouting. However, it was a bit to aggressive in doing that. If only the width changed in a geometrychange, it would not relayout if widthMaximum was true. However, if the width goes from 0 to greater than 0, the value of widthMaximum should have actually been false (but we would only notice this after relayouting). Thus, don't skip relayouting in that case. Amends 56ade46b4234bb828b8e4f9a6bf83b5687bd122e, which fixed the same issue, but for height. Fixes: QTBUG-83408 Fixes: QTBUG-33608 Change-Id: I14b610c703eb0496c71de7b12ad9fcf16842af64 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> (cherry picked from commit 127c79fb7fda16b9a48ce8c425d1700d1aa7502d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/quick/qquicktext/data/elideZeroWidth.qml23
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp10
2 files changed, 33 insertions, 0 deletions
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 308c6b5091..fe3f696dfa 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");