From d169873541ca6f6725e9ce5bfbbf9941f1823a1f Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 17 Dec 2009 16:18:56 +1000 Subject: 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 --- src/declarative/qml/qmlengine.cpp | 10 ++++++++++ src/declarative/qml/qmlengine_p.h | 1 + src/declarative/qml/qmlpropertycache.cpp | 7 ++++--- 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::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 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 *); -- cgit v0.12