aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlvme.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2012-05-24 16:28:54 +0100
committerQt by Nokia <qt-info@nokia.com>2012-06-06 16:51:07 +0200
commita26d7aef3ce61ac0515cf8a324c8badd13bdb017 (patch)
tree1dd22962a7c40df451ae7f9465cf2ca4e4185cb7 /src/qml/qml/qqmlvme.cpp
parent1fcb3d512c37625e6dfdbd045c755e8d6aca8c57 (diff)
Disallow parent changes for QML created objects
Currently this is protected with a QML_PARENT_TEST environment variable to allow the rest of QtQuick to be updated before it is enforced. Change-Id: I4dd3644cbbce91d67f24c9556637f97eafb00638 Reviewed-by: Kent Hansen <kent.hansen@nokia.com> Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src/qml/qml/qqmlvme.cpp')
-rw-r--r--src/qml/qml/qqmlvme.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp
index bb245198bf..b9924e384c 100644
--- a/src/qml/qml/qqmlvme.cpp
+++ b/src/qml/qml/qqmlvme.cpp
@@ -609,13 +609,14 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
customParser->setCustomData(o, DATAS.at(instr.data));
}
if (!objects.isEmpty()) {
- QObject *parent = objects.top();
+ QObject *parent = objects.at(objects.count() - 1 - (instr.parentToSuper?1:0));
#if 0 // ### refactor
if (o->isWidgetType() && parent->isWidgetType())
static_cast<QWidget*>(o)->setParent(static_cast<QWidget*>(parent));
else
#endif
QQml_setParent_noEvent(o, parent);
+ ddata->parentFrozen = true;
}
objects.push(o);
QML_END_INSTR(CreateCppObject)
@@ -642,9 +643,10 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
ddata->prevContextObject = &CTXT->contextObjects;
CTXT->contextObjects = ddata;
- QObject *parent = objects.top();
+ QObject *parent = objects.at(objects.count() - 1 - (instr.parentToSuper?1:0));
QQml_setParent_noEvent(o, parent);
+ ddata->parentFrozen = true;
objects.push(o);
QML_END_INSTR(CreateSimpleObject)
@@ -905,19 +907,16 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
QML_BEGIN_INSTR(StoreValueSource)
QObject *obj = objects.pop();
QQmlPropertyValueSource *vs = reinterpret_cast<QQmlPropertyValueSource *>(reinterpret_cast<char *>(obj) + instr.castValue);
- QObject *target = objects.at(objects.count() - 1 - instr.owner);
-
- obj->setParent(target);
+ QObject *target = obj->parent();
vs->setTarget(QQmlPropertyPrivate::restore(target, instr.property, CTXT));
QML_END_INSTR(StoreValueSource)
QML_BEGIN_INSTR(StoreValueInterceptor)
QObject *obj = objects.pop();
QQmlPropertyValueInterceptor *vi = reinterpret_cast<QQmlPropertyValueInterceptor *>(reinterpret_cast<char *>(obj) + instr.castValue);
- QObject *target = objects.at(objects.count() - 1 - instr.owner);
+ QObject *target = obj->parent();
QQmlProperty prop =
QQmlPropertyPrivate::restore(target, instr.property, CTXT);
- obj->setParent(target);
vi->setTarget(prop);
QQmlVMEMetaObject *mo = QQmlVMEMetaObject::get(target);
Q_ASSERT(mo);