Q_DECLARE_METATYPE_TEMPLATE_1ARG(QQueue)
Q_DECLARE_METATYPE_TEMPLATE_1ARG(QStack)
Q_DECLARE_METATYPE_TEMPLATE_1ARG(QSet)
-Q_DECLARE_METATYPE_TEMPLATE_1ARG(QSharedPointer)
Q_DECLARE_METATYPE_TEMPLATE_1ARG(QLinkedList)
Q_DECLARE_METATYPE_TEMPLATE_2ARG(QHash)
Q_DECLARE_METATYPE_TEMPLATE_2ARG(QMap)
Q_DECLARE_METATYPE_TEMPLATE_2ARG(QPair)
+template <typename T, bool = QtPrivate::IsPointerToTypeDerivedFromQObject<T*>::Value>
+struct QMetaTypeIdSharedPointerQObjectStar
+{
+ enum {
+ Defined = 0
+ };
+};
+
+template <typename T>
+struct QMetaTypeIdSharedPointerQObjectStar<T, /* IsPointerToTypeDerivedFromQObject */ true>
+{
+ enum {
+ Defined = 1
+ };
+ static int qt_metatype_id()
+ {
+ static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
+ if (!metatype_id.load()) {
+ metatype_id.storeRelease(qRegisterNormalizedMetaType< QSharedPointer<T> >( QByteArray("QSharedPointer<") + T::staticMetaObject.className() + ">",
+ reinterpret_cast< QSharedPointer<T> *>(quintptr(-1))));
+ }
+ return metatype_id.loadAcquire();
+ }
+};
+
+template <typename T>
+struct QMetaTypeId< QSharedPointer<T> > : public QMetaTypeIdSharedPointerQObjectStar<T>
+{
+};
+
inline QMetaType::QMetaType(const ExtensionFlag extensionFlags, const QMetaTypeInterface *info,
Creator creator,
Deleter deleter,
qRegisterMetaTypeStreamOperators<QVariant>("QVariant");
}
-Q_DECLARE_METATYPE(QSharedPointer<QObject>)
-
typedef QHash<int, uint> IntUIntHash;
Q_DECLARE_METATYPE(IntUIntHash)
typedef QMap<int, uint> IntUIntMap;
int m_int;
};
+class MyObject : public QObject
+{
+ Q_OBJECT
+public:
+ MyObject(QObject *parent = 0)
+ : QObject(parent)
+ {
+ }
+};
+typedef MyObject* MyObjectPtr;
+Q_DECLARE_METATYPE(MyObjectPtr)
+
void tst_QMetaType::automaticTemplateRegistration()
{
{
F(QVector, TYPE) \
F(QQueue, TYPE) \
F(QStack, TYPE) \
- F(QSet, TYPE) \
- F(QSharedPointer, TYPE)
+ F(QSet, TYPE)
#define PRINT_1ARG_TEMPLATE(RealName, ...) \
FOR_EACH_1ARG_TEMPLATE_TYPE(CREATE_AND_VERIFY_CONTAINER, RealName)
#endif // Q_COMPILER_VARIADIC_MACROS
+#define TEST_QSHAREDPOINTER(FULLTYPE) \
+ { \
+ FULLTYPE sp = FULLTYPE::create(); \
+ QVariant v = QVariant::fromValue(sp); \
+ QCOMPARE(v.typeName(), #FULLTYPE); \
+ }
+
+ TEST_QSHAREDPOINTER(QSharedPointer<QObject>)
+ TEST_QSHAREDPOINTER(QSharedPointer<QFile>)
+ TEST_QSHAREDPOINTER(QSharedPointer<QTemporaryFile>)
+ TEST_QSHAREDPOINTER(QSharedPointer<MyObject>)
+
+#undef TEST_QSHAREDPOINTER
+
}
template <typename T>