summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-06-25 12:47:57 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-06-25 12:52:55 (GMT)
commitc938ec01a76bf56f667481e626fbb9252ee3d05d (patch)
tree063a742b510a71b1ed1ee6b3fc41a9288fe23273 /tests
parent2d9aaff174d70953ed1f98c24baaf0c9abac78aa (diff)
downloadQt-c938ec01a76bf56f667481e626fbb9252ee3d05d.zip
Qt-c938ec01a76bf56f667481e626fbb9252ee3d05d.tar.gz
Qt-c938ec01a76bf56f667481e626fbb9252ee3d05d.tar.bz2
make invokable constructors work with classes in namespace
Use the fully qualified classname at relevant places in the moc-generated code. Also, QMetaObject::newInstance() needs to strip the namespace part, since the constructor signatures don't contain the fully qualified name. Task-number: 246064 Reviewed-by: Simon Hausmann
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qmetaobject/tst_qmetaobject.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp
index 95d19e2..dea0ffb 100644
--- a/tests/auto/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp
@@ -605,6 +605,19 @@ void tst_QMetaObject::invokeCustomTypes()
QCOMPARE(obj.sum, 3);
}
+namespace NamespaceWithConstructibleClass
+{
+
+class ConstructibleClass : public QObject
+{
+ Q_OBJECT
+public:
+ Q_INVOKABLE ConstructibleClass(QObject *parent = 0)
+ : QObject(parent) {}
+};
+
+}
+
void tst_QMetaObject::invokeMetaConstructor()
{
const QMetaObject *mo = &QtTestObject::staticMetaObject;
@@ -619,6 +632,15 @@ void tst_QMetaObject::invokeMetaConstructor()
QCOMPARE(obj2->parent(), (QObject*)&obj);
QVERIFY(qobject_cast<QtTestObject*>(obj2) != 0);
}
+ // class in namespace
+ const QMetaObject *nsmo = &NamespaceWithConstructibleClass::ConstructibleClass::staticMetaObject;
+ {
+ QtTestObject obj;
+ QObject *obj2 = nsmo->newInstance(Q_ARG(QObject*, &obj));
+ QVERIFY(obj2 != 0);
+ QCOMPARE(obj2->parent(), (QObject*)&obj);
+ QVERIFY(qobject_cast<NamespaceWithConstructibleClass::ConstructibleClass*>(obj2) != 0);
+ }
}
void tst_QMetaObject::normalizedSignature_data()