Commit e615cf82 authored by Erik Verbruggen's avatar Erik Verbruggen
Browse files

Fixed regression when assigning an object binding to an array property.

parent d1602650
......@@ -187,6 +187,9 @@ public:
QString typeName() const
{ return m_type; }
bool isList() const
{ return m_isList; }
};
class FakeMetaObject {
......@@ -859,6 +862,15 @@ QString QmlObjectValue::propertyType(const QString &propertyName) const
return QString();
}
bool QmlObjectValue::isListProperty(const QString &name) const
{
int idx = _metaObject->propertyIndex(name);
if (idx == -1)
return false;
FakeMetaProperty prop = _metaObject->property(idx);
return prop.isList();
}
bool QmlObjectValue::isEnum(const QString &typeName) const
{
return _metaObject->enumeratorIndex(typeName) != -1;
......
......@@ -418,6 +418,7 @@ public:
int minorVersion() const;
QString defaultPropertyName() const;
QString propertyType(const QString &propertyName) const;
bool isListProperty(const QString &name) const;
bool isEnum(const QString &typeName) const;
protected:
......
......@@ -303,15 +303,23 @@ public:
return true;
}
bool isArrayProperty(const Interpreter::Value *value)
bool isArrayProperty(const Interpreter::Value *value, const Interpreter::ObjectValue *containingObject, const QString &name)
{
if (!value)
return false;
const Interpreter::ObjectValue *objectValue = value->asObjectValue();
if (!objectValue)
return false;
if (objectValue && objectValue->prototype(m_context) == m_engine->arrayPrototype())
return true;
return objectValue->prototype(m_context) == m_engine->arrayPrototype();
for (const Interpreter::ObjectValue *iter = containingObject; iter; iter = iter->prototype(m_context)) {
if (iter->property(name, m_context) == m_engine->arrayPrototype())
return true;
if (const Interpreter::QmlObjectValue *qmlIter = dynamic_cast<const Interpreter::QmlObjectValue *>(iter)) {
if (qmlIter->isListProperty(name))
return true;
}
}
return false;
}
QVariant convertToVariant(const QString &astValue, UiQualifiedId *propertyId)
......@@ -580,10 +588,12 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
if (binding->hasOnToken) {
// skip value sources
} else {
const Interpreter::Value *propertyType;
if (context->lookupProperty(binding->qualifiedId, &propertyType) || typeName == QLatin1String("Qt/PropertyChanges")) {
const Interpreter::Value *propertyType = 0;
const Interpreter::ObjectValue *containingObject = 0;
QString name;
if (context->lookupProperty(binding->qualifiedId, &propertyType, &containingObject, &name) || typeName == QLatin1String("Qt/PropertyChanges")) {
AbstractProperty modelProperty = modelNode.property(astPropertyName);
if (context->isArrayProperty(propertyType)) {
if (context->isArrayProperty(propertyType, containingObject, name)) {
syncArrayProperty(modelProperty, QList<QmlJS::AST::UiObjectMember*>() << member, context, differenceHandler);
} else {
syncNodeProperty(modelProperty, binding, context, differenceHandler);
......
......@@ -133,7 +133,6 @@ void TestCore::testModelCreateCoreModel()
// TODO: this need to e updated for states
void TestCore::loadEmptyCoreModel()
{
QList<QDeclarativeError> errors;
QFile file(":/fx/empty.qml");
QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment