From 091d8259e0fd820801ee2ffaf87d4f42cdc52c20 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Sun, 19 Jan 2014 14:22:54 +0100 Subject: [new compiler] Correct the use of default property When a type declares a new default property, then the old default property continues to apply to its own bindings. Change-Id: Iafeec772baa4e1a430b09eed0b348b83984246cd Reviewed-by: Lars Knoll --- src/qml/compiler/qqmltypecompiler.cpp | 9 ++------- src/qml/compiler/qv4compileddata_p.h | 2 +- src/qml/qml/qqmlobjectcreator.cpp | 10 ++-------- 3 files changed, 5 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index 9232aef5c8..13b0575337 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -793,8 +793,7 @@ void QQmlComponentAndAliasResolver::findAndRegisterImplicitComponents(const QtQm PropertyResolver propertyResolver(propertyCache); - bool defaultPropertyQueried = false; - QQmlPropertyData *defaultProperty = 0; + QQmlPropertyData *defaultProperty = obj->indexOfDefaultProperty != -1 ? propertyCache->parent()->defaultProperty() : propertyCache->defaultProperty(); for (QtQml::Binding *binding = obj->bindings->first; binding; binding = binding->next) { if (binding->type != QV4::CompiledData::Binding::Type_Object) @@ -815,10 +814,6 @@ void QQmlComponentAndAliasResolver::findAndRegisterImplicitComponents(const QtQm bool notInRevision = false; pd = propertyResolver.property(propertyName, ¬InRevision); } else { - if (!defaultPropertyQueried) { - defaultProperty = propertyCache->defaultProperty(); - defaultPropertyQueried = true; - } pd = defaultProperty; } if (!pd || !pd->isQObject()) @@ -1182,7 +1177,7 @@ bool QQmlPropertyValidator::validateObject(int objectIndex) PropertyResolver propertyResolver(propertyCache); - QQmlPropertyData *defaultProperty = propertyCache->defaultProperty(); + QQmlPropertyData *defaultProperty = obj->indexOfDefaultProperty != -1 ? propertyCache->parent()->defaultProperty() : propertyCache->defaultProperty(); const QV4::CompiledData::Binding *binding = obj->bindingTable(); for (quint32 i = 0; i < obj->nBindings; ++i, ++binding) { diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index f9e85ef080..83e8058be1 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -371,7 +371,7 @@ struct Object // it will be the name of the attached type. quint32 inheritedTypeNameIndex; quint32 idIndex; - quint32 indexOfDefaultProperty; + qint32 indexOfDefaultProperty; // -1 means no default property declared in this object quint32 nFunctions; quint32 offsetToFunctions; quint32 nProperties; diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 2cacb0e546..24a8327722 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -588,8 +588,7 @@ void QmlObjectCreator::setupBindings() qSwap(_currentList, savedList); QQmlPropertyData *property = 0; - bool defaultPropertyQueried = false; - QQmlPropertyData *defaultProperty = 0; + QQmlPropertyData *defaultProperty = _compiledObject->indexOfDefaultProperty != -1 ? _propertyCache->parent()->defaultProperty() : _propertyCache->defaultProperty(); QString id = stringAt(_compiledObject->idIndex); if (!id.isEmpty()) { @@ -615,13 +614,8 @@ void QmlObjectCreator::setupBindings() if (!property || (i > 0 && (binding - 1)->propertyNameIndex != binding->propertyNameIndex)) { if (!name.isEmpty()) property = _propertyCache->property(name, _qobject, context); - else { - if (!defaultPropertyQueried) { - defaultProperty = _propertyCache->defaultProperty(); - defaultPropertyQueried = true; - } + else property = defaultProperty; - } if (property && property->isQList()) { void *argv[1] = { (void*)&_currentList }; -- cgit v1.2.3