diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-01-10 13:54:11 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2019-02-21 15:05:32 +0000 |
commit | ae9be1a63d7b579fb5bb8b4bf903f1a3efe7168f (patch) | |
tree | e2b6f7d28297aa66278a7113d2df7d57009501fe /tests | |
parent | f6cf0442df52e8018f724a9234d2ae0267ecba85 (diff) |
moc: Parse namespaces from other files
We can parse the namespaces in order to find the enums in them and
populate the related metaobjects of the current file's classes. The
symbol clashes are avoided by only generating metaobjects for namespaces
defined in the same file.
Fixes: QTBUG-71966
Fixes: QTBUG-72069
Change-Id: Ibdf21c3f9dae48d95b0952b3e220b4c29e30ecb8
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/tools/moc/tst_moc.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 74ddfd5620..0acc90fd11 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -3847,6 +3847,14 @@ static void checkEnum(const QMetaEnum &enumerator, const QByteArray &name, const } } +class EnumFromNamespaceClass : public QObject +{ + Q_OBJECT + Q_PROPERTY(FooNamespace::Enum1 prop READ prop CONSTANT) +public: + FooNamespace::Enum1 prop() { return FooNamespace::Enum1::Key2; } +}; + void tst_Moc::testQNamespace() { QCOMPARE(TestQNamespace::staticMetaObject.enumeratorCount(), 4); @@ -3874,6 +3882,11 @@ void tst_Moc::testQNamespace() QCOMPARE(FooNamespace::staticMetaObject.enumeratorCount(), 1); QCOMPARE(FooNamespace::FooNestedNamespace::staticMetaObject.enumeratorCount(), 2); QCOMPARE(FooNamespace::FooNestedNamespace::FooMoreNestedNamespace::staticMetaObject.enumeratorCount(), 1); + + EnumFromNamespaceClass obj; + const QVariant prop = obj.property("prop"); + QCOMPARE(prop.type(), QMetaType::Int); + QCOMPARE(prop.toInt(), int(FooNamespace::Enum1::Key2)); } void tst_Moc::cxx17Namespaces() |