diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2012-01-06 13:43:40 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-25 08:46:40 +0100 |
commit | 00c8984b4e48b2a7eadfee6c3cd0cbb19f586118 (patch) | |
tree | a4f3f1c958d43b737ef669578c35789134f34341 /src | |
parent | 79ebb1621e6cdb68a4ad107c8ac80eadb9c60366 (diff) |
moc: Use QMetaType::QVariant as the type for QVariant
QMetaType::QVariant has existed as a proper type for almost two
years, but the qvariant_nameToType function was written in 2006.
Using QMetaType::QVariant means QVariant can be treated just like
any other type. We can get rid of those hacky checks for LastType,
and the remaining checks become more readable.
The fact that QMetaProperty::{type,userType}() returned LastType
(0xffffffff) for QVariants was never documented (LastType itself is
internal). But there are other Qt modules that assume so. I'll fix
the ones I know about (qtdeclarative, qtscript, activeqt).
Change-Id: I799b9079bb8bbb1fe76c132525440b30415cbac5
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qmetaobject.cpp | 14 | ||||
-rw-r--r-- | src/corelib/kernel/qmetaobjectbuilder.cpp | 2 | ||||
-rw-r--r-- | src/tools/moc/generator.cpp | 2 |
3 files changed, 4 insertions, 14 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 4c2cddf818..5395a4ae2c 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -2105,8 +2105,6 @@ QVariant::Type QMetaProperty::type() const uint flags = mobj->d.data[handle + 2]; uint type = flags >> 24; - if (type == 0xff) // special value for QVariant - type = QVariant::LastType; if (type) return QVariant::Type(type); if (isEnumType()) { @@ -2241,8 +2239,6 @@ QVariant QMetaProperty::read(const QObject *object) const uint flags = mobj->d.data[handle + 2]; const char *typeName = mobj->d.stringdata + mobj->d.data[handle + 1]; t = (flags >> 24); - if (t == 0xff) // special value for QVariant - t = QVariant::LastType; if (t == QVariant::Invalid) t = QMetaType::type(typeName); if (t == QVariant::Invalid) @@ -2262,7 +2258,7 @@ QVariant QMetaProperty::read(const QObject *object) const int status = -1; QVariant value; void *argv[] = { 0, &value, &status }; - if (t == QVariant::LastType) { + if (t == QMetaType::QVariant) { argv[0] = &value; } else { value = QVariant(t, (void*)0); @@ -2273,7 +2269,7 @@ QVariant QMetaProperty::read(const QObject *object) const if (status != -1) return value; - if (t != QVariant::LastType && argv[0] != value.data()) + if (t != QMetaType::QVariant && argv[0] != value.data()) // pointer or reference return QVariant((QVariant::Type)t, argv[0]); return value; @@ -2312,8 +2308,6 @@ bool QMetaProperty::write(QObject *object, const QVariant &value) const int handle = priv(mobj->d.data)->propertyData + 3*idx; uint flags = mobj->d.data[handle + 2]; t = flags >> 24; - if (t == 0xff) // special value for QVariant - t = QVariant::LastType; if (t == QVariant::Invalid) { const char *typeName = mobj->d.stringdata + mobj->d.data[handle + 1]; const char *vtypeName = value.typeName(); @@ -2324,7 +2318,7 @@ bool QMetaProperty::write(QObject *object, const QVariant &value) const } if (t == QVariant::Invalid) return false; - if (t != QVariant::LastType && t != (uint)value.userType() && (t < QMetaType::User && !v.convert((QVariant::Type)t))) + if (t != QMetaType::QVariant && t != (uint)value.userType() && (t < QMetaType::User && !v.convert((QVariant::Type)t))) return false; } @@ -2338,7 +2332,7 @@ bool QMetaProperty::write(QObject *object, const QVariant &value) const // interception of property writes. int flags = 0; void *argv[] = { 0, &v, &status, &flags }; - if (t == QVariant::LastType) + if (t == QMetaType::QVariant) argv[0] = &v; else argv[0] = v.data(); diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index 7837cb9451..49cc8842cd 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -80,8 +80,6 @@ uint qvariant_nameToType(const char* name) if (!name) return 0; - if (strcmp(name, "QVariant") == 0) - return 0xffffffff; if (strcmp(name, "QCString") == 0) return QMetaType::QByteArray; if (strcmp(name, "Q_LLONG") == 0) diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 605e751df4..dc902ece33 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -54,8 +54,6 @@ uint qvariant_nameToType(const char* name) if (!name) return 0; - if (strcmp(name, "QVariant") == 0) - return 0xffffffff; if (strcmp(name, "QCString") == 0) return QMetaType::QByteArray; if (strcmp(name, "Q_LLONG") == 0) |