aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTeemu Holappa <teemu.holappa@qt.io>2019-10-11 14:30:00 +0300
committerTeemu Holappa <teemu.holappa@qt.io>2019-10-11 17:26:43 +0300
commit76da530aca3876cc083988b883658673168821a4 (patch)
treeca00d6c689f8172bdb8bce304c2985af35f9463f /tests
parent45f95e74297ab3778965319c175a6d726f9c8afe (diff)
Fix float value binding to an integer
Also NaN values are casted to an integer which causes illegal integer values. Task-number: QTBUG-72442 Change-Id: I3ff3c8e4dc493600360448ea30d949c0017da8c3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlbinding/data/nanPropertyToInt.qml14
-rw-r--r--tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp11
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlbinding/data/nanPropertyToInt.qml b/tests/auto/qml/qqmlbinding/data/nanPropertyToInt.qml
new file mode 100644
index 0000000000..366dbf0464
--- /dev/null
+++ b/tests/auto/qml/qqmlbinding/data/nanPropertyToInt.qml
@@ -0,0 +1,14 @@
+import QtQuick 2.11
+
+Item {
+ visible: true
+ width: 320
+ height: 200
+ property int val: other.val
+
+ Rectangle {
+ id: other
+ anchors.fill: parent;
+ property int val: undefined / 2
+ }
+}
diff --git a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
index 2c2d311ff7..2610402455 100644
--- a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
+++ b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
@@ -56,6 +56,7 @@ private slots:
void bindingOverwriting();
void bindToQmlComponent();
void bindingDoesNoWeirdConversion();
+ void bindNaNToInt();
private:
QQmlEngine engine;
@@ -398,6 +399,16 @@ void tst_qqmlbinding::bindingDoesNoWeirdConversion()
QVERIFY(colorLabel);
}
+//QTBUG-72442
+void tst_qqmlbinding::bindNaNToInt()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("nanPropertyToInt.qml"));
+ QScopedPointer<QQuickItem> item(qobject_cast<QQuickItem*>(c.create()));
+
+ QVERIFY(item != nullptr);
+ QCOMPARE(item->property("val").toInt(), 0);
+}
QTEST_MAIN(tst_qqmlbinding)
#include "tst_qqmlbinding.moc"