From 4b8ceb41aed352f10d36db5284453f425dbc5f3f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 30 Dec 2011 12:00:09 +0100 Subject: Store the is-a QObject fact with the metatype declaration. This is a source incompatible change for Q_DECLARE_METATYPE(T*), which now requires T to be fully defined. The consequences of this are: * Forward declared types can no longer be declared as a metatype. (though this is a very uncommon thing to do). There is a trivial workaround where necessary. Change-Id: Id74c40088b8c0b466fcd7c55abd616f69acc82c8 Reviewed-by: Lars Knoll --- .../corelib/kernel/qmetatype/tst_qmetatype.cpp | 39 +++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp') diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 3107fe49d9..de93c21d43 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -596,21 +596,50 @@ Q_DECLARE_TYPEINFO(CustomMovable, Q_MOVABLE_TYPE); QT_END_NAMESPACE Q_DECLARE_METATYPE(CustomMovable); +class CustomObject : public QObject +{ + Q_OBJECT +public: + CustomObject(QObject *parent = 0) + : QObject(parent) + { + + } +}; +Q_DECLARE_METATYPE(CustomObject*); + +struct SecondBase {}; + +class CustomMultiInheritanceObject : public QObject, SecondBase +{ + Q_OBJECT +public: + CustomMultiInheritanceObject(QObject *parent = 0) + : QObject(parent) + { + + } +}; +Q_DECLARE_METATYPE(CustomMultiInheritanceObject*); + void tst_QMetaType::flags_data() { QTest::addColumn("type"); QTest::addColumn("isMovable"); QTest::addColumn("isComplex"); + QTest::addColumn("isPointerToQObject"); #define ADD_METATYPE_TEST_ROW(MetaTypeName, MetaTypeId, RealType) \ - QTest::newRow(#RealType) << MetaTypeId << bool(!QTypeInfo::isStatic) << bool(QTypeInfo::isComplex); + QTest::newRow(#RealType) << MetaTypeId << bool(!QTypeInfo::isStatic) << bool(QTypeInfo::isComplex) << bool(QtPrivate::IsPointerToTypeDerivedFromQObject::Value); QT_FOR_EACH_STATIC_CORE_CLASS(ADD_METATYPE_TEST_ROW) QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(ADD_METATYPE_TEST_ROW) QT_FOR_EACH_STATIC_CORE_POINTER(ADD_METATYPE_TEST_ROW) #undef ADD_METATYPE_TEST_ROW - QTest::newRow("TestSpace::Foo") << ::qMetaTypeId() << false << true; - QTest::newRow("Whity") << ::qMetaTypeId >() << false << true; - QTest::newRow("CustomMovable") << ::qMetaTypeId() << true << true; + QTest::newRow("TestSpace::Foo") << ::qMetaTypeId() << false << true << false; + QTest::newRow("Whity") << ::qMetaTypeId >() << false << true << false; + QTest::newRow("CustomMovable") << ::qMetaTypeId() << true << true << false; + QTest::newRow("CustomObject*") << ::qMetaTypeId() << true << false << true; + QTest::newRow("CustomMultiInheritanceObject*") << ::qMetaTypeId() << true << false << true; } void tst_QMetaType::flags() @@ -618,10 +647,12 @@ void tst_QMetaType::flags() QFETCH(int, type); QFETCH(bool, isMovable); QFETCH(bool, isComplex); + QFETCH(bool, isPointerToQObject); QCOMPARE(bool(QMetaType::typeFlags(type) & QMetaType::NeedsConstruction), isComplex); QCOMPARE(bool(QMetaType::typeFlags(type) & QMetaType::NeedsDestruction), isComplex); QCOMPARE(bool(QMetaType::typeFlags(type) & QMetaType::MovableType), isMovable); + QCOMPARE(bool(QMetaType::typeFlags(type) & QMetaType::PointerToQObject), isPointerToQObject); } void tst_QMetaType::construct_data() -- cgit v1.2.3