aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlobjectcreator.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-06-23 13:20:23 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2017-08-02 16:32:43 +0000
commit49a11e882059ee1729f776722e085dd21d378c36 (patch)
tree1b0fe9a471766d97d03602502acc57c00df93b36 /src/qml/qml/qqmlobjectcreator.cpp
parent97165444ac6954766d53c3eb62eb1614644c7264 (diff)
Use QQmlType by value
QQmlType is now refcounted, and we need to use it by value, to control it's lifetime properly. This is required, so we can clean up the QQmlMetaTypeData cache on engine destruction and with trimComponentCache() Task-number: QTBUG-61536 Change-Id: If86391c86ea20a646ded7c9925d8f743f628fb91 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlobjectcreator.cpp')
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 2cbcfbbfb6..6867aaad75 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -613,11 +613,11 @@ void QQmlObjectCreator::setPropertyValue(const QQmlPropertyData *property, const
}
}
-static QQmlType *qmlTypeForObject(QObject *object)
+static QQmlType qmlTypeForObject(QObject *object)
{
- QQmlType *type = 0;
+ QQmlType type;
const QMetaObject *mo = object->metaObject();
- while (mo && !type) {
+ while (mo && !type.isValid()) {
type = QQmlMetaType::qmlType(mo);
mo = mo->superClass();
}
@@ -654,7 +654,7 @@ void QQmlObjectCreator::setupBindings(bool applyDeferredBindings)
} else if (binding) {
QQmlValueTypeProxyBinding *proxy = static_cast<QQmlValueTypeProxyBinding *>(binding);
- if (qmlTypeForObject(_bindingTarget)) {
+ if (qmlTypeForObject(_bindingTarget).isValid()) {
quint32 bindingSkipList = 0;
QQmlPropertyData *defaultProperty = _compiledObject->indexOfDefaultPropertyOrAlias != -1 ? _propertyCache->parent()->defaultProperty() : _propertyCache->defaultProperty();
@@ -712,15 +712,15 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con
Q_ASSERT(stringAt(qmlUnit->objectAt(binding->value.objectIndex)->inheritedTypeNameIndex).isEmpty());
QV4::CompiledData::ResolvedTypeReference *tr = resolvedTypes.value(binding->propertyNameIndex);
Q_ASSERT(tr);
- QQmlType *attachedType = tr->type;
- if (!attachedType) {
+ QQmlType attachedType = tr->type;
+ if (!attachedType.isValid()) {
QQmlTypeNameCache::Result res = context->imports->query(stringAt(binding->propertyNameIndex));
if (res.isValid())
attachedType = res.type;
else
return false;
}
- const int id = attachedType->attachedPropertiesId(QQmlEnginePrivate::get(engine));
+ const int id = attachedType.attachedPropertiesId(QQmlEnginePrivate::get(engine));
QObject *qmlObject = qmlAttachedPropertiesObjectById(id, _qobject);
if (!populateInstance(binding->value.objectIndex, qmlObject, qmlObject, /*value type property*/0))
return false;
@@ -850,10 +850,10 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con
if (binding->type == QV4::CompiledData::Binding::Type_Object) {
if (binding->flags & QV4::CompiledData::Binding::IsOnAssignment) {
// ### determine value source and interceptor casts ahead of time.
- QQmlType *type = qmlTypeForObject(createdSubObject);
- Q_ASSERT(type);
+ QQmlType type = qmlTypeForObject(createdSubObject);
+ Q_ASSERT(type.isValid());
- int valueSourceCast = type->propertyValueSourceCast();
+ int valueSourceCast = type.propertyValueSourceCast();
if (valueSourceCast != -1) {
QQmlPropertyValueSource *vs = reinterpret_cast<QQmlPropertyValueSource *>(reinterpret_cast<char *>(createdSubObject) + valueSourceCast);
QObject *target = createdSubObject->parent();
@@ -865,7 +865,7 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con
vs->setTarget(prop);
return true;
}
- int valueInterceptorCast = type->propertyValueInterceptorCast();
+ int valueInterceptorCast = type.propertyValueInterceptorCast();
if (valueInterceptorCast != -1) {
QQmlPropertyValueInterceptor *vi = reinterpret_cast<QQmlPropertyValueInterceptor *>(reinterpret_cast<char *>(createdSubObject) + valueInterceptorCast);
QObject *target = createdSubObject->parent();
@@ -1060,13 +1060,13 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
QV4::CompiledData::ResolvedTypeReference *typeRef = resolvedTypes.value(obj->inheritedTypeNameIndex);
Q_ASSERT(typeRef);
installPropertyCache = !typeRef->isFullyDynamicType;
- QQmlType *type = typeRef->type;
- if (type) {
+ QQmlType type = typeRef->type;
+ if (type.isValid()) {
Q_QML_OC_PROFILE(sharedState->profiler, profiler.update(
- compilationUnit, obj, type->qmlTypeName(), context->url()));
+ compilationUnit, obj, type.qmlTypeName(), context->url()));
void *ddataMemory = 0;
- type->create(&instance, &ddataMemory, sizeof(QQmlData));
+ type.create(&instance, &ddataMemory, sizeof(QQmlData));
if (!instance) {
recordError(obj->location, tr("Unable to create object of type %1").arg(stringAt(obj->inheritedTypeNameIndex)));
return 0;
@@ -1080,11 +1080,11 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
p->declarativeData = ddata;
}
- const int parserStatusCast = type->parserStatusCast();
+ const int parserStatusCast = type.parserStatusCast();
if (parserStatusCast != -1)
parserStatus = reinterpret_cast<QQmlParserStatus*>(reinterpret_cast<char *>(instance) + parserStatusCast);
- customParser = type->customParser();
+ customParser = type.customParser();
if (sharedState->rootContext && sharedState->rootContext->isRootObjectInCreation) {
QQmlData *ddata = QQmlData::get(instance, /*create*/true);