diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2009-09-03 00:52:45 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2009-09-03 00:52:45 (GMT) |
commit | c452c44d8cee138dcdd62f8c0f0db48b4ada5c40 (patch) | |
tree | 6901c957445a2fcae7559168752dd6b063f1af89 | |
parent | 9260c597cc45e15943ad851f934ebb6e5ac1010a (diff) | |
download | Qt-c452c44d8cee138dcdd62f8c0f0db48b4ada5c40.zip Qt-c452c44d8cee138dcdd62f8c0f0db48b4ada5c40.tar.gz Qt-c452c44d8cee138dcdd62f8c0f0db48b4ada5c40.tar.bz2 |
Fix a bug in the qmlvme, which lead to an assert on valid QML.
As QmlComponents are created outside the CreateObject instruction, they
could be created with an uninitalized declarative data member.
Also this patch sets the column on CreateObject instructions too.
Reviewed-by: Aaron Kennedy
-rw-r--r-- | src/declarative/qml/qmlcompiler.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlinstruction_p.h | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlvme.cpp | 8 |
3 files changed, 11 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index c0f7bfd..c411b8d 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -781,6 +781,7 @@ void QmlCompiler::genObject(QmlParser::Object *obj) QmlInstruction create; create.type = QmlInstruction::CreateObject; create.line = obj->location.start.line; + create.create.column = obj->location.start.column; create.create.data = -1; if (!obj->custom.isEmpty()) create.create.data = output->indexForByteArray(obj->custom); @@ -937,6 +938,7 @@ void QmlCompiler::genComponent(QmlParser::Object *obj) QmlInstruction create; create.type = QmlInstruction::CreateComponent; create.line = root->location.start.line; + create.createComponent.column = root->location.start.column; create.createComponent.endLine = root->location.end.line; output->bytecode << create; int count = output->bytecode.count(); diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h index ede06a2..3c6af1b 100644 --- a/src/declarative/qml/qmlinstruction_p.h +++ b/src/declarative/qml/qmlinstruction_p.h @@ -284,6 +284,7 @@ public: } assignSignalObject; struct { int count; + ushort column; int endLine; int metaObject; } createComponent; diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index a49cbd3..4d133e3 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -222,6 +222,14 @@ QObject *QmlVME::run(QStack<QObject *> &stack, QmlContext *ctxt, QmlCompiledData case QmlInstruction::CreateComponent: { QObject *qcomp = new QmlComponent(ctxt->engine(), comp, ii + 1, instr.createComponent.count, stack.isEmpty() ? 0 : stack.top()); + + QmlEngine::setContextForObject(qcomp, ctxt); + QmlDeclarativeData *ddata = QmlDeclarativeData::get(qcomp); + Q_ASSERT(ddata); + ddata->outerContext = ctxt; + ddata->lineNumber = instr.line; + ddata->columnNumber = instr.create.column; + stack.push(qcomp); ii += instr.createComponent.count; } |