From: Gunnar Sletta Date: Mon, 6 Feb 2012 16:57:43 +0000 (+0100) Subject: Avoid recursive parent chains in QQuickItem X-Git-Tag: qt-v5.0.0-alpha1~478 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5a5393fd53eea23b0de5a69ad9d706a2ee2502cc;p=profile%2Fivi%2Fqtdeclarative.git Avoid recursive parent chains in QQuickItem Change-Id: I47b666cfacd804c4302236f0a4b371ca7b382c3d Reviewed-by: Michael Brasser --- diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 30a23db..166ffe8 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -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;