diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-07-26 14:15:49 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-27 06:09:11 +0200 |
commit | 54c2d685512fdeac2d5b6eeaf25ed738c4fd99ba (patch) | |
tree | 27acf485b787f825525d20b7a160d45fde678360 /tests/auto/qml/qqmlpropertymap | |
parent | 73842034aac7b9788add4f1ba6cf7a9ec6057598 (diff) |
Allow access to signals and slots in QQmlPropertyMap inheritors
Allow inheritors of QQmlPropertyMap to pass the static meta object
information needed to support their signals and slots. If the correct
pointer is not provided to the constructor, it is not accessible via
the virtual metaObject() function during construction.
Task-number: QTBUG-26400
Change-Id: Ide8c6d3568e4abd4c48e0aa60e6fa05a9c2a11cf
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlpropertymap')
-rw-r--r-- | tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp index 4e39ad3a41..3fd9dbec8f 100644 --- a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp +++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp @@ -64,6 +64,7 @@ private slots: void crashBug(); void QTBUG_17868(); + void metaObjectAccessibility(); }; void tst_QQmlPropertyMap::insert() @@ -280,6 +281,48 @@ void tst_QQmlPropertyMap::QTBUG_17868() } +class MyEnhancedPropertyMap : public QQmlPropertyMap +{ + Q_OBJECT +public: + MyEnhancedPropertyMap() : QQmlPropertyMap(this) {} + +signals: + void testSignal(); + +public slots: + void testSlot() {} +}; + +namespace +{ + QStringList messages; + void msgHandler(QtMsgType, const char *msg) + { + messages << QLatin1String(msg); + } +} + +void tst_QQmlPropertyMap::metaObjectAccessibility() +{ + messages.clear(); + QtMsgHandler old = qInstallMsgHandler(msgHandler); + + QQmlEngine engine; + + MyEnhancedPropertyMap map; + + // Verify that signals and slots of QQmlPropertyMap-derived classes are accessible + QObject::connect(&map, SIGNAL(testSignal()), &engine, SIGNAL(quit())); + QObject::connect(&engine, SIGNAL(quit()), &map, SLOT(testSlot())); + + QCOMPARE(map.metaObject()->className(), "MyEnhancedPropertyMap"); + + qInstallMsgHandler(old); + + QCOMPARE(messages.count(), 0); +} + QTEST_MAIN(tst_QQmlPropertyMap) #include "tst_qqmlpropertymap.moc" |