diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-12-17 06:18:56 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-12-17 06:31:38 (GMT) |
commit | d169873541ca6f6725e9ce5bfbbf9941f1823a1f (patch) | |
tree | 9b7fd46f2f50caa43751c9042ec1d4ed32b77ded | |
parent | 2bd2433c606a6ddb745b57776d83f326d85037f5 (diff) | |
download | Qt-d169873541ca6f6725e9ce5bfbbf9941f1823a1f.zip Qt-d169873541ca6f6725e9ce5bfbbf9941f1823a1f.tar.gz Qt-d169873541ca6f6725e9ce5bfbbf9941f1823a1f.tar.bz2 |
Set correct property flags for custom property types.
If a property type was a composite object pointer
(e.g. property MyObject obj), it was not being correctly identified as an
object type.
Task-number: QTBUG-6335
Reviewed-by: Aaron Kennedy
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 10 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine_p.h | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlpropertycache.cpp | 7 | ||||
-rw-r--r-- | src/declarative/qml/qmlpropertycache_p.h | 2 |
4 files changed, 16 insertions, 4 deletions
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 6b66095..f541631 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -1527,6 +1527,16 @@ int QmlEnginePrivate::qmlListType(int t) const return QmlMetaType::qmlListType(t); } +QmlMetaType::TypeCategory QmlEnginePrivate::typeCategory(int t) const +{ + if (m_compositeTypes.contains(t)) + return QmlMetaType::Object; + else if (m_qmlLists.contains(t)) + return QmlMetaType::QmlList; + else + return QmlMetaType::typeCategory(t); +} + const QMetaObject *QmlEnginePrivate::rawMetaObjectForType(int t) const { QHash<int, QmlCompiledData*>::ConstIterator iter = m_compositeTypes.find(t); diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index c3db6cf..96297ea 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -263,6 +263,7 @@ public: bool isQmlList(int) const; bool isObject(int); int qmlListType(int) const; + QmlMetaType::TypeCategory typeCategory(int) const; const QMetaObject *rawMetaObjectForType(int) const; const QMetaObject *metaObjectForType(int) const; QHash<int, int> m_qmlLists; diff --git a/src/declarative/qml/qmlpropertycache.cpp b/src/declarative/qml/qmlpropertycache.cpp index 6ba6028..bc7d7de 100644 --- a/src/declarative/qml/qmlpropertycache.cpp +++ b/src/declarative/qml/qmlpropertycache.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE Q_DECLARE_METATYPE(QScriptValue); -void QmlPropertyCache::Data::load(const QMetaProperty &p) +void QmlPropertyCache::Data::load(const QMetaProperty &p, QmlEngine *engine) { propType = p.userType(); if (QVariant::Type(propType) == QVariant::LastType) @@ -69,7 +69,8 @@ void QmlPropertyCache::Data::load(const QMetaProperty &p) } else if (p.isEnumType()) { flags |= Data::IsEnumType; } else { - QmlMetaType::TypeCategory cat = QmlMetaType::typeCategory(propType); + QmlMetaType::TypeCategory cat = engine ? QmlEnginePrivate::get(engine)->typeCategory(propType) + : QmlMetaType::typeCategory(propType); if (cat == QmlMetaType::Object) flags |= Data::IsQObjectDerived; else if (cat == QmlMetaType::List) @@ -174,7 +175,7 @@ void QmlPropertyCache::update(QmlEngine *engine, const QMetaObject *metaObject) RData *data = new RData; data->identifier = enginePriv->objectClass->createPersistentIdentifier(propName); - data->load(p); + data->load(p, engine); indexCache[ii] = data; diff --git a/src/declarative/qml/qmlpropertycache_p.h b/src/declarative/qml/qmlpropertycache_p.h index 613f4dd..50b4cf2 100644 --- a/src/declarative/qml/qmlpropertycache_p.h +++ b/src/declarative/qml/qmlpropertycache_p.h @@ -97,7 +97,7 @@ public: int coreIndex; int notifyIndex; - void load(const QMetaProperty &); + void load(const QMetaProperty &, QmlEngine *engine = 0); void load(const QMetaMethod &); QString name(QObject *); QString name(const QMetaObject *); |