summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/kernel/qmetatype.cpp15
-rw-r--r--src/corelib/kernel/qmetatype.h5
-rw-r--r--src/corelib/kernel/qvariant.h3
3 files changed, 20 insertions, 3 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index be506b4..8f2d025 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -133,6 +133,7 @@ QT_BEGIN_NAMESPACE
\value Float \c float
\value QObjectStar QObject *
\value QWidgetStar QWidget *
+ \value QVariant QVariant
\value QColorGroup QColorGroup
\value QCursor QCursor
@@ -300,6 +301,7 @@ static const struct { const char * typeName; int typeNameLength; int type; } typ
QT_ADD_STATIC_METATYPE("float", QMetaType::Float),
QT_ADD_STATIC_METATYPE("QObject*", QMetaType::QObjectStar),
QT_ADD_STATIC_METATYPE("QWidget*", QMetaType::QWidgetStar),
+ QT_ADD_STATIC_METATYPE("QVariant", QMetaType::QVariant),
/* Type aliases - order doesn't matter */
QT_ADD_STATIC_METATYPE("unsigned long", QMetaType::ULong),
@@ -686,6 +688,9 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
case QMetaType::QVariantList:
stream << *static_cast<const NS(QVariantList)*>(data);
break;
+ case QMetaType::QVariant:
+ stream << *static_cast<const NS(QVariant)*>(data);
+ break;
#endif
case QMetaType::QByteArray:
stream << *static_cast<const NS(QByteArray)*>(data);
@@ -888,6 +893,9 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
case QMetaType::QVariantList:
stream >> *static_cast< NS(QVariantList)*>(data);
break;
+ case QMetaType::QVariant:
+ stream >> *static_cast< NS(QVariant)*>(data);
+ break;
#endif
case QMetaType::QByteArray:
stream >> *static_cast< NS(QByteArray)*>(data);
@@ -1055,6 +1063,8 @@ void *QMetaType::construct(int type, const void *copy)
return new NS(QVariantHash)(*static_cast<const NS(QVariantHash)*>(copy));
case QMetaType::QVariantList:
return new NS(QVariantList)(*static_cast<const NS(QVariantList)*>(copy));
+ case QMetaType::QVariant:
+ return new NS(QVariant)(*static_cast<const NS(QVariant)*>(copy));
#endif
case QMetaType::QByteArray:
return new NS(QByteArray)(*static_cast<const NS(QByteArray)*>(copy));
@@ -1150,6 +1160,8 @@ void *QMetaType::construct(int type, const void *copy)
return new NS(QVariantHash);
case QMetaType::QVariantList:
return new NS(QVariantList);
+ case QMetaType::QVariant:
+ return new NS(QVariant);
#endif
case QMetaType::QByteArray:
return new NS(QByteArray);
@@ -1291,6 +1303,9 @@ void QMetaType::destroy(int type, void *data)
case QMetaType::QVariantList:
delete static_cast< NS(QVariantList)* >(data);
break;
+ case QMetaType::QVariant:
+ delete static_cast< NS(QVariant)* >(data);
+ break;
#endif
case QMetaType::QByteArray:
delete static_cast< NS(QByteArray)* >(data);
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 2ed4a1f..98ed4bd 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -86,7 +86,8 @@ public:
FirstCoreExtType = 128 /* VoidStar */,
VoidStar = 128, Long = 129, Short = 130, Char = 131, ULong = 132,
UShort = 133, UChar = 134, Float = 135, QObjectStar = 136, QWidgetStar = 137,
- LastCoreExtType = QWidgetStar,
+ QVariant = 138,
+ LastCoreExtType = QVariant,
// This logic must match the one in qglobal.h
#if defined(QT_COORD_TYPE)
@@ -353,6 +354,7 @@ class QVector2D;
class QVector3D;
class QVector4D;
class QQuaternion;
+class QVariant;
QT_END_NAMESPACE
@@ -421,6 +423,7 @@ Q_DECLARE_BUILTIN_METATYPE(QVector2D, QVector2D)
Q_DECLARE_BUILTIN_METATYPE(QVector3D, QVector3D)
Q_DECLARE_BUILTIN_METATYPE(QVector4D, QVector4D)
Q_DECLARE_BUILTIN_METATYPE(QQuaternion, QQuaternion)
+Q_DECLARE_BUILTIN_METATYPE(QVariant, QVariant)
QT_END_HEADER
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 9628dbf..cb2825c 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -589,8 +589,7 @@ template<typename T> inline T qvariant_cast(const QVariant &v)
template<> inline QVariant qvariant_cast<QVariant>(const QVariant &v)
{
- static const int vid = qRegisterMetaType<QVariant>("QVariant");
- if (vid == v.userType())
+ if (v.userType() == QMetaType::QVariant)
return *reinterpret_cast<const QVariant *>(v.constData());
return v;
}