diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2022-06-03 15:12:10 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-06-15 09:43:01 +0200 |
| commit | fb3a81623a3d39289d508f504bb0308be443ce50 (patch) | |
| tree | 85b0eb53394c61dbf384e9470949a18e196437bc /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | 48ae7468afc06d52844badb3f5f41114f67a360f (diff) | |
QmlCompiler: Reject conversions via QJSValue
Those are generally less efficient than what the interpreter would do,
they can have side effects, and they can throw exceptions. We don't want
to deal with any of that. Most of those implicit conversions have
explicit equivalents. For those that don't we can add them.
Pick-to: 6.2 6.4
Fixes: QTBUG-104010
Change-Id: I62898db92219386c94f2a6c9b56f6fb0b7578832
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 103e0171b8..bbf4b4691f 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -120,6 +120,7 @@ private slots: void boundComponents(); void invisibleListElementType(); void typePropertyClash(); + void objectToString(); }; void tst_QmlCppCodegen::simpleBinding() @@ -2194,6 +2195,20 @@ void tst_QmlCppCodegen::typePropertyClash() QCOMPARE(o->objectName(), u"Size: 5"_s); } +void tst_QmlCppCodegen::objectToString() +{ + QQmlEngine engine; + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/toString.qml"_s)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + + QTest::ignoreMessage(QtWarningMsg, "qrc:/TestTypes/toString.qml:6: no"); + QScopedPointer<QObject> o(c.create()); + QVERIFY(!o.isNull()); + + QCOMPARE(o->property("yes").toString(), u"yes yes"_s); + QCOMPARE(o->property("no").toString(), u" no"_s); // throws, but that is ignored +} + void tst_QmlCppCodegen::runInterpreted() { #ifdef Q_OS_ANDROID |
