diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2022-11-30 10:48:21 +0100 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-12-02 13:35:42 +0100 |
| commit | 8bc748e7e52d19a078b0281c5b8265a42015ffdb (patch) | |
| tree | a823402ed7c48272ae5310387f0cd708048d3b30 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | b7bc1874a5cf1738ce7885b8bef0e16d0f83f56f (diff) | |
QmlCompiler: Fix various kinds of enum lookup
* If we got an object type exposed as namespace, we still need to add
the "*" to get its augmentedInternalName(). Otherwise we cannot get
its metaobject, needed to look up enums.
* Enums cannot be shadowed. The shadow check will produce garbage if we
try to check because an enum lookup also does not use the accumulator,
which then contains some artifact from a previous operation.
* If we find a property lookup on a plain QMetaObject* we have to
immediately return in order to not confuse it with attached
properties.
Pick-to: 6.4 6.2
Fixes: QTBUG-109048
Change-Id: If9e3b4806e4d773de9cf48f1b3750b684a8c8f69
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.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index d2868e023a..3f76090e6f 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -2,6 +2,7 @@ #include <data/birthdayparty.h> #include <data/cppbaseclass.h> +#include <data/enumproblems.h> #include <data/objectwithmethod.h> #include <QtQml/private/qqmlengine_p.h> @@ -149,6 +150,7 @@ private slots: void consoleObject(); void multiForeign(); void namespaceWithEnum(); + void enumProblems(); }; void tst_QmlCppCodegen::initTestCase() @@ -2881,6 +2883,25 @@ void tst_QmlCppCodegen::namespaceWithEnum() QCOMPARE(o->property("i").toInt(), 2); } +void tst_QmlCppCodegen::enumProblems() +{ + QQmlEngine engine; + QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/enumProblems.qml"_s)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> outer(c.create()); + QVERIFY(!outer.isNull()); + QObject *inner = outer->property("o").value<QObject *>(); + QVERIFY(inner); + + Foo *bar = inner->property("bar").value<Foo *>(); + QVERIFY(bar); + QCOMPARE(bar->type(), Foo::Component); + + Foo *fighter = inner->property("fighter").value<Foo *>(); + QVERIFY(fighter); + QCOMPARE(fighter->type(), Foo::Fighter); +} + QTEST_MAIN(tst_QmlCppCodegen) #include "tst_qmlcppcodegen.moc" |
