diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-01-17 12:16:07 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-20 11:49:42 +0100 |
commit | 65a02ef32f7131f5e0b87dd18b4f81486d507ae3 (patch) | |
tree | 07bcb66e6f18641991e5f8532a5e5503780bdfee /src/qml/compiler/qqmlcodegenerator.cpp | |
parent | 3a9e7f056f487c9740621750067781d33a7c9f34 (diff) |
[new compiler] Fix refcounting leaks with property caches
The TypeReference is not copy-safe, as it holds refcounted property cache
pointers. For the new compiler code path, don't copy them but keep pointers to
TypeReference objects around. Also make sure to ref the root property cache
correctly and avoid the unnecessary addref for the property cache when creating
new vme meta objects (initial refcount is 1).
Change-Id: I0c4b952c8300c2167d926d9c35b8579fd505d596
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qqmlcodegenerator.cpp')
-rw-r--r-- | src/qml/compiler/qqmlcodegenerator.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/qml/compiler/qqmlcodegenerator.cpp b/src/qml/compiler/qqmlcodegenerator.cpp index 22ae1228c7..46bb07f8bc 100644 --- a/src/qml/compiler/qqmlcodegenerator.cpp +++ b/src/qml/compiler/qqmlcodegenerator.cpp @@ -1639,8 +1639,8 @@ bool SignalHandlerConverter::convertSignalHandlerExpressionsToFunctionDeclaratio QString elementName = stringAt(obj->inheritedTypeNameIndex); if (elementName.isEmpty()) continue; - QQmlCompiledData::TypeReference &tr = unit->resolvedTypes[obj->inheritedTypeNameIndex]; - if (tr.type && tr.type->customParser()) + QQmlCompiledData::TypeReference *tr = unit->resolvedTypes.value(obj->inheritedTypeNameIndex); + if (tr && tr->type && tr->type->customParser()) continue; QQmlPropertyCache *cache = unit->propertyCaches.value(objectIndex); Q_ASSERT(cache); @@ -1660,7 +1660,8 @@ bool SignalHandlerConverter::convertSignalHandlerExpressionsToFunctionDeclaratio // Attached property? if (binding->type == QV4::CompiledData::Binding::Type_AttachedProperty) { QmlObject *attachedObj = parsedQML->objects[binding->value.objectIndex]; - QQmlType *type = unit->resolvedTypes.value(binding->propertyNameIndex).type; + QQmlCompiledData::TypeReference *typeRef = unit->resolvedTypes.value(binding->propertyNameIndex); + QQmlType *type = typeRef ? typeRef->type : 0; const QMetaObject *attachedType = type ? type->attachedPropertiesType() : 0; if (!attachedType) COMPILE_EXCEPTION(binding->location, tr("Non-existent attached object")); @@ -1703,7 +1704,8 @@ bool SignalHandlerConverter::convertSignalHandlerExpressionsToFunctionDeclaratio const QString &originalPropertyName = stringAt(binding->propertyNameIndex); - const QQmlType *type = unit->resolvedTypes.value(obj->inheritedTypeNameIndex).type; + QQmlCompiledData::TypeReference *typeRef = unit->resolvedTypes.value(obj->inheritedTypeNameIndex); + const QQmlType *type = typeRef ? typeRef->type : 0; if (type) { COMPILE_EXCEPTION(binding->location, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(typeName).arg(originalPropertyName).arg(type->module()).arg(type->majorVersion()).arg(type->minorVersion())); } else { |