aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-12-01 19:05:51 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-12-06 19:35:50 +0100
commit1003626e6ac98bc2a1eb0d2ed5df8727612f37ae (patch)
treebdae1ee9ecf9396cd214cc0cb6f04dca9b6072be /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parentf8f50d12dcefa4d7d6a7fbc56d973f68c6b9b0ae (diff)
QmlCompiler: Fix return type calculation
We can return void from a function, explicitly or implicitly, and we need to be able to wrap that into a QVariant. In order to explicitly return void, we need the void type to be exposed and understood. Pick-to: 6.2 Change-Id: I513cabb25469b89a85b5d212a6825a037400729d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 4ccac7bb5b..68f7102ecb 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -108,6 +108,7 @@ private slots:
void jsMathObject();
void intEnumCompare();
void attachedSelf();
+ void functionReturningVoid();
};
void tst_QmlCppCodegen::simpleBinding()
@@ -1613,6 +1614,22 @@ void tst_QmlCppCodegen::attachedSelf()
QVERIFY(qvariant_cast<QObject *>(handle->property("rect")) != nullptr);
}
+void tst_QmlCppCodegen::functionReturningVoid()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/functionReturningVoid.qml"_qs));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(o);
+
+ // It should be able to call the methods and wrap the void values into invalid QVariants,
+ // without crashing.
+ QVERIFY(o->metaObject()->indexOfProperty("aa") >= 0);
+ QVERIFY(o->metaObject()->indexOfProperty("bb") >= 0);
+ QVERIFY(!o->property("aa").isValid());
+ QVERIFY(!o->property("bb").isValid());
+}
+
void tst_QmlCppCodegen::runInterpreted()
{
if (qEnvironmentVariableIsSet("QV4_FORCE_INTERPRETER"))