diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2023-04-18 10:55:20 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-04-19 09:30:58 +0200 |
| commit | b3281f123ea5a8c0e5f8c63fa1568cf7414f9c14 (patch) | |
| tree | e9ba0dc42572bf4ae9d75bbdd3b1f151de48be2f /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | 50f4ed0e444aeb2367232b3b81958c352630f45e (diff) | |
Fix content pointer check for QObject*
It can actually be null rather than undefined. We need to generate a
separate check for that and output the correct error messages.
Amends commit 05f56d7c78754855c643470ad4e8dfd35c96f927
Change-Id: Ia795e31805181640cd5be19359af51067d3fc8d6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index e5e7597cb6..bb9789d63d 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -177,6 +177,7 @@ private slots: void boolCoercions(); void ambiguousAs(); void boolPointerMerge(); + void mergedObjectReadWrite(); }; void tst_QmlCppCodegen::initTestCase() @@ -3558,6 +3559,31 @@ void tst_QmlCppCodegen::boolPointerMerge() QCOMPARE(item->property("ppp").toInt(), -99); } +void tst_QmlCppCodegen::mergedObjectReadWrite() +{ + QQmlEngine e; + { + QQmlComponent c(&e, QUrl(u"qrc:/qt/qml/TestTypes/mergedObjectRead.qml"_s)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QTest::ignoreMessage(QtDebugMsg, "null"); + QTest::ignoreMessage( + QtWarningMsg, QRegularExpression("TypeError: Cannot read property 'x' of null")); + QScopedPointer<QObject> o(c.create()); + QVERIFY(!o.isNull()); + } + + { + QQmlComponent c(&e, QUrl(u"qrc:/qt/qml/TestTypes/mergedObjectWrite.qml"_s)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QTest::ignoreMessage( + QtWarningMsg, + QRegularExpression( + "TypeError: Value is null and could not be converted to an object")); + QScopedPointer<QObject> o(c.create()); + QVERIFY(!o.isNull()); + } +} + QTEST_MAIN(tst_QmlCppCodegen) #include "tst_qmlcppcodegen.moc" |
