diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2022-02-16 10:47:04 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-02-18 12:13:47 +0100 |
| commit | d0f4e0c037cf61eb5bb559755ee7c9ce6cf6b7dc (patch) | |
| tree | df0ded3ef90e50a5c384d15b6120b0012cc4bbb2 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | bd968fa6ff07cda5d96dd5c9851bb1c98ee4f318 (diff) | |
QmlCompiler: Perform QVariant conversion in JavaScript semantics
In JavaScript we have a number of extra conversions not covered by
qvariant_cast. Therefore, add a method to perform a QVariant conversion
in JavaScript semantics to QJSEngine, and use that in the compiler.
Pick-to: 6.3
Fixes: QTBUG-100883
Change-Id: I8b0bfa0974bc6b339d2601fb373859bc710788c8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 0c69294876..db70df4522 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -120,6 +120,7 @@ private slots: void infinities(); void blockComments(); void functionLookup(); + void objectInVar(); }; void tst_QmlCppCodegen::simpleBinding() @@ -1804,6 +1805,24 @@ void tst_QmlCppCodegen::functionLookup() QCOMPARE(result.toString(), QStringLiteral("a99")); } +void tst_QmlCppCodegen::objectInVar() +{ + QQmlEngine engine; + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/objectInVar.qml"_qs)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QVERIFY(o); + QCOMPARE(qvariant_cast<QObject*>(o->property("thing")), o.data()); + + bool result = false; + QVERIFY(QMetaObject::invokeMethod(o.data(), "doThing", Q_RETURN_ARG(bool, result))); + QVERIFY(result); + + o->setProperty("thing", QVariant::fromValue<std::nullptr_t>(nullptr)); + QVERIFY(QMetaObject::invokeMethod(o.data(), "doThing", Q_RETURN_ARG(bool, result))); + QVERIFY(!result); +} + void tst_QmlCppCodegen::runInterpreted() { if (qEnvironmentVariableIsSet("QV4_FORCE_INTERPRETER")) |
