QmlDesigner.Instances: The engine does set the QObject parent first

We should follow the engine and set the QObject parent first.
Actually some items (e.g. menus) do not like it differently.

A note: The engine seems to always set the QObject parent even for items.

Change-Id: I700e8802300b8eee093f73ea11e07c4cdb0338aa
Reviewed-by: Marco Bubke <marco.bubke@digia.com>
This commit is contained in:
Thomas Hartmann
2013-04-30 11:25:47 +02:00
parent 7a5836d257
commit bdeb9371ee

View File

@@ -378,6 +378,12 @@ void ObjectNodeInstance::addToNewProperty(QObject *object, QObject *newParent, c
{
QQmlProperty property(newParent, newParentProperty, context());
QQuickItem *quickItem = qobject_cast<QQuickItem*>(object);
//The engine sets the QObject before it does reparent
if (object && !quickItem)
object->setParent(newParent);
if (isList(property)) {
QQmlListReference list = qvariant_cast<QQmlListReference>(property.read());
@@ -391,8 +397,6 @@ void ObjectNodeInstance::addToNewProperty(QObject *object, QObject *newParent, c
property.write(objectToVariant(object));
}
QQuickItem *quickItem = qobject_cast<QQuickItem*>(object);
if (object && !(quickItem && quickItem->parentItem()))
object->setParent(newParent);