Skip to content

Commit

Permalink
Avoid recursive parent chains in QQuickItem
Browse files Browse the repository at this point in the history
Change-Id: I47b666cfacd804c4302236f0a4b371ca7b382c3d
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
  • Loading branch information
Gunnar Sletta authored and Qt by Nokia committed Feb 7, 2012
1 parent 96860e3 commit 5a5393f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/quick/items/qquickitem.cpp
Expand Up @@ -1869,6 +1869,17 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
if (parentItem == d->parentItem)
return;

if (parentItem) {
QQuickItem *itemAncestor = parentItem->parentItem();
while (itemAncestor != 0) {
if (itemAncestor == this) {
qWarning("QQuickItem::setParentItem: Parent is already part of this items subtree.");
return;
}
itemAncestor = itemAncestor->parentItem();
}
}

d->removeFromDirtyList();

QQuickItem *oldParentItem = d->parentItem;
Expand Down

0 comments on commit 5a5393f

Please sign in to comment.