aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/types/qqmllistmodel.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-03-02 20:35:57 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-02 22:29:27 +0100
commit06479ddfe3a9319fd371cd50f4d2f2316d51055a (patch)
tree6239592028143718b64a9e6621c59e8185a7698a /src/qml/types/qqmllistmodel.cpp
parent57665bf23a00eca240d26c6267ca2bed1a052c0b (diff)
[new compiler] Add the correct object index to the custom parser
Without the correct index the calls to astForBinding run out of bounds. Fixes tst_qqmllistmodel crash. Change-Id: I6fb8b77866cbf247e7373cdbece6833c92be3615 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/types/qqmllistmodel.cpp')
-rw-r--r--src/qml/types/qqmllistmodel.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp
index 0dc1c2c25c..fbf3c091c2 100644
--- a/src/qml/types/qqmllistmodel.cpp
+++ b/src/qml/types/qqmllistmodel.cpp
@@ -2385,10 +2385,10 @@ bool QQmlListModelParser::compileProperty(const QQmlCustomParserProperty &prop,
return true;
}
-bool QQmlListModelParser::compileProperty(const QV4::CompiledData::QmlUnit *qmlUnit, const QV4::CompiledData::Binding *binding, QList<QQmlListModelParser::ListInstruction> &instr, QByteArray &data)
+bool QQmlListModelParser::compileProperty(const QV4::CompiledData::QmlUnit *qmlUnit, int objectIndex, const QV4::CompiledData::Binding *binding, QList<QQmlListModelParser::ListInstruction> &instr, QByteArray &data)
{
- const quint32 targetObjectIndex = binding->value.objectIndex;
if (binding->type >= QV4::CompiledData::Binding::Type_Object) {
+ const quint32 targetObjectIndex = binding->value.objectIndex;
const QV4::CompiledData::Object *target = qmlUnit->objectAt(targetObjectIndex);
QString objName = qmlUnit->header.stringAt(target->inheritedTypeNameIndex);
if (objName != listElementTypeName) {
@@ -2427,7 +2427,7 @@ bool QQmlListModelParser::compileProperty(const QV4::CompiledData::QmlUnit *qmlU
li.dataIdx = ref;
instr << li;
- if (!compileProperty(qmlUnit, binding, instr, data))
+ if (!compileProperty(qmlUnit, targetObjectIndex, binding, instr, data))
return false;
li.type = ListInstruction::Pop;
@@ -2466,7 +2466,7 @@ bool QQmlListModelParser::compileProperty(const QV4::CompiledData::QmlUnit *qmlU
int v = evaluateEnum(script, &ok);
if (!ok) {
using namespace QQmlJS;
- AST::Node *node = astForBinding(targetObjectIndex, binding->value.compiledScriptIndex);
+ AST::Node *node = astForBinding(objectIndex, binding->value.compiledScriptIndex);
if (AST::ExpressionStatement *stmt = AST::cast<AST::ExpressionStatement*>(node))
node = stmt->expression;
AST::StringLiteral *literal = 0;
@@ -2552,7 +2552,7 @@ QByteArray QQmlListModelParser::compile(const QList<QQmlCustomParserProperty> &c
return rv;
}
-QByteArray QQmlListModelParser::compile(const QV4::CompiledData::QmlUnit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
+QByteArray QQmlListModelParser::compile(const QV4::CompiledData::QmlUnit *qmlUnit, int objectIndex, const QList<const QV4::CompiledData::Binding *> &bindings)
{
QList<ListInstruction> instr;
QByteArray data;
@@ -2564,7 +2564,7 @@ QByteArray QQmlListModelParser::compile(const QV4::CompiledData::QmlUnit *qmlUni
error(binding, QQmlListModel::tr("ListModel: undefined property '%1'").arg(propName));
return QByteArray();
}
- if (!compileProperty(qmlUnit, binding, instr, data))
+ if (!compileProperty(qmlUnit, objectIndex, binding, instr, data))
return QByteArray();
}