aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-08-21 15:52:39 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-08-23 15:30:11 +0200
commit8d9dfd33478c30567bbab073eed899b169dd4386 (patch)
tree0dfd6e7944a43fcd1eb072822766b6cafda5357c /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parentd554714a6c2d5f1ffdbca8e22f3c29fc03d28ba6 (diff)
QmlCompiler: Fix conversion from/to void
We can convert everything to void, but we can only convert from void if the result is either void or the invalid type. Pick-to: 6.6 Fixes: QTBUG-116088 Change-Id: I532055405865c5b1581f79cc5d76c253bce6138d 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.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index ec5f400fe2..881253f3ea 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -206,6 +206,7 @@ private slots:
void variantMapLookup();
void variantReturn();
void variantlist();
+ void voidConversion();
void voidFunction();
};
@@ -4189,6 +4190,23 @@ void tst_QmlCppCodegen::variantlist()
QCOMPARE(things[1].toInt(), 30);
}
+void tst_QmlCppCodegen::voidConversion()
+{
+ QQmlEngine engine;
+ const QUrl url(u"qrc:/qt/qml/TestTypes/voidConversion.qml"_s);
+ QQmlComponent c(&engine, url);
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+
+ QTest::ignoreMessage(
+ QtWarningMsg,
+ qPrintable(url.toString() + u":8: Error: Cannot assign [undefined] to QPointF"_s));
+
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(o);
+
+ QCOMPARE(o->property("p"), QPointF(20, 10));
+}
+
void tst_QmlCppCodegen::voidFunction()
{
QQmlEngine engine;