diff options
author | Liang Qi <liang.qi@qt.io> | 2017-11-15 09:11:24 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-11-15 09:11:25 +0100 |
commit | 984ba6977201f8fbd94d44a2b67519e1faf458cc (patch) | |
tree | 4ee9af0e9014240ecd9c25079fbdfcbdcda7a4f9 /src/svg | |
parent | f1ba95141c54b452edd737e9adb3461f303eb850 (diff) | |
parent | 18a2adad907523ea31251ff0b62e3321241a40fa (diff) | |
download | qtsvg-984ba6977201f8fbd94d44a2b67519e1faf458cc.tar.gz |
Merge remote-tracking branch 'origin/5.9' into 5.10v5.10.0-rc3v5.10.0-rc2v5.10.0-rc1v5.10.05.10.0
Change-Id: I2c5f1f592e2141b93fa274124a96f2a63b83acdb
Diffstat (limited to 'src/svg')
-rw-r--r-- | src/svg/qsvggraphics.cpp | 5 | ||||
-rw-r--r-- | src/svg/qsvghandler.cpp | 2 | ||||
-rw-r--r-- | src/svg/qsvgnode.cpp | 11 | ||||
-rw-r--r-- | src/svg/qsvgnode_p.h | 1 |
4 files changed, 18 insertions, 1 deletions
diff --git a/src/svg/qsvggraphics.cpp b/src/svg/qsvggraphics.cpp index b1047eb..5b273af 100644 --- a/src/svg/qsvggraphics.cpp +++ b/src/svg/qsvggraphics.cpp @@ -465,6 +465,9 @@ QSvgUse::QSvgUse(const QPointF &start, QSvgNode *parent, QSvgNode *node) void QSvgUse::draw(QPainter *p, QSvgExtraStates &states) { + if (Q_UNLIKELY(!m_link || isDescendantOf(m_link))) + return; + applyStyle(p, states); if (!m_start.isNull()) { @@ -553,7 +556,7 @@ QSvgNode::Type QSvgVideo::type() const QRectF QSvgUse::bounds(QPainter *p, QSvgExtraStates &states) const { QRectF bounds; - if (m_link) { + if (Q_LIKELY(m_link && !isDescendantOf(m_link))) { p->translate(m_start); bounds = m_link->transformedBounds(p, states); p->translate(-m_start); diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index f6b4320..6c0e742 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -3338,6 +3338,8 @@ static QSvgNode *createUseNode(QSvgNode *parent, if (group) { QSvgNode *link = group->scopeNode(linkId); if (link) { + if (parent->isDescendantOf(link)) + qCWarning(lcSvgHandler, "link #%s is recursive!", qPrintable(linkId)); QPointF pt; if (!xStr.isNull() || !yStr.isNull()) { QSvgHandler::LengthType type; 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 "<<prop->type()<< " ("<< id <<") "<<"to "<<this<<this->type(); diff --git a/src/svg/qsvgnode_p.h b/src/svg/qsvgnode_p.h index f9f6202..f2502e4 100644 --- a/src/svg/qsvgnode_p.h +++ b/src/svg/qsvgnode_p.h @@ -113,6 +113,7 @@ public: virtual void draw(QPainter *p, QSvgExtraStates &states) =0; QSvgNode *parent() const; + bool isDescendantOf(const QSvgNode *parent) const; void appendStyleProperty(QSvgStyleProperty *prop, const QString &id); void applyStyle(QPainter *p, QSvgExtraStates &states) const; |