From 18a2adad907523ea31251ff0b62e3321241a40fa Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 14 Nov 2017 14:47:08 +0100 Subject: Fix crash on recursive self-referral in element Referring to an ancestor in a element would lead to endless recursion. Add checks to avoid recursion, and also emit a warning while parsing. Task-number: QTBUG-64425 Change-Id: I9ee1b9bfef13796cc3f387ff8579c6b13bc4ae9a Reviewed-by: Andy Shaw --- src/svg/qsvgnode.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/svg/qsvgnode.cpp') diff --git a/src/svg/qsvgnode.cpp b/src/svg/qsvgnode.cpp index e504522..14aaea4 100644 --- a/src/svg/qsvgnode.cpp +++ b/src/svg/qsvgnode.cpp @@ -57,6 +57,17 @@ QSvgNode::~QSvgNode() } +bool QSvgNode::isDescendantOf(const QSvgNode *parent) const +{ + const QSvgNode *n = this; + while (n) { + if (n == parent) + return true; + n = n->m_parent; + } + return false; +} + void QSvgNode::appendStyleProperty(QSvgStyleProperty *prop, const QString &id) { //qDebug()<<"appending "<type()<< " ("<< id <<") "<<"to "<type(); -- cgit v1.2.1