Fix metatype trait for types that are both QObject and Q_GADGET
Fixes ambiguous template instantiation for types that derive from both a QObject and Q_GADGET. For such types we treat them only as QObjects as they extend the functionality of the gadget. Task-number: QTBUG-68803 Change-Id: Ic42766034e14e5df43c4e6f7811e2c0be1dc7e74 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
parent
0ac09c40f2
commit
35e005bc4f
@ -1413,8 +1413,8 @@ namespace QtPrivate
|
||||
static char checkType(void (X::*)());
|
||||
static void *checkType(void (T::*)());
|
||||
enum {
|
||||
IsRealGadget = sizeof(checkType(&T::qt_check_for_QGADGET_macro)) == sizeof(void *),
|
||||
IsGadgetOrDerivedFrom = true
|
||||
IsRealGadget = !IsPointerToTypeDerivedFromQObject<T*>::Value && sizeof(checkType(&T::qt_check_for_QGADGET_macro)) == sizeof(void *),
|
||||
IsGadgetOrDerivedFrom = !IsPointerToTypeDerivedFromQObject<T*>::Value
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1696,11 +1696,21 @@ public:
|
||||
Q_ENUM(MyEnum)
|
||||
};
|
||||
|
||||
class MyQObjectFromGadget : public QObject, public MyGadget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MyQObjectFromGadget(QObject *parent = 0)
|
||||
: QObject(parent)
|
||||
{}
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(MyGadget);
|
||||
Q_DECLARE_METATYPE(MyGadget*);
|
||||
Q_DECLARE_METATYPE(const QMetaObject *);
|
||||
Q_DECLARE_METATYPE(Qt::ScrollBarPolicy);
|
||||
Q_DECLARE_METATYPE(MyGadget::MyEnum);
|
||||
Q_DECLARE_METATYPE(MyQObjectFromGadget*);
|
||||
|
||||
void tst_QMetaType::metaObject_data()
|
||||
{
|
||||
@ -1719,6 +1729,7 @@ void tst_QMetaType::metaObject_data()
|
||||
QTest::newRow("MyGadget*") << ::qMetaTypeId<MyGadget*>() << &MyGadget::staticMetaObject << false << true << false;
|
||||
QTest::newRow("MyEnum") << ::qMetaTypeId<MyGadget::MyEnum>() << &MyGadget::staticMetaObject << false << false << false;
|
||||
QTest::newRow("Qt::ScrollBarPolicy") << ::qMetaTypeId<Qt::ScrollBarPolicy>() << &QObject::staticQtMetaObject << false << false << false;
|
||||
QTest::newRow("MyQObjectFromGadget*") << ::qMetaTypeId<MyQObjectFromGadget*>() << &MyQObjectFromGadget::staticMetaObject << false << false << true;
|
||||
|
||||
QTest::newRow("GadgetDerivedAndTyped<int>") << ::qMetaTypeId<GadgetDerivedAndTyped<int>>() << &GadgetDerivedAndTyped<int>::staticMetaObject << true << false << false;
|
||||
QTest::newRow("GadgetDerivedAndTyped<int>*") << ::qMetaTypeId<GadgetDerivedAndTyped<int>*>() << &GadgetDerivedAndTyped<int>::staticMetaObject << false << true << false;
|
||||
|
Loading…
Reference in New Issue
Block a user