diff options
author | Matthias Rauter <matthias.rauter@qt.io> | 2024-01-03 15:59:23 +0100 |
---|---|---|
committer | Matthias Rauter <matthias.rauter@qt.io> | 2024-01-06 11:17:30 +0100 |
commit | 35faa32a04a26a31c495dd56cec4bbe3734af0d6 (patch) | |
tree | f382de30cfafcd69843e16c938f1907114c7cc5e /src | |
parent | 604fe97dd110dbac52d9fafc81549788df33b482 (diff) |
Remove nodeStringList in favor of QSvgNode::typeName()
When adding node types (e.g. mask) the QSvgStyleSelector_nodeString
was not updated. With this patch we use QSvgNode::typeName()
instead. The return values were adjusted to ensure that we are
backwards compatible.
This list is required to make CSS work properly. The missing strings
triggered a crash when testing the resvg test suit. This patch fixes
the crash.
Pick-to: 6.7
Change-Id: Ia715664c87d531b125627554129b8e4d930ced44
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/svg/qsvghandler.cpp | 24 | ||||
-rw-r--r-- | src/svg/qsvgnode.cpp | 62 |
2 files changed, 31 insertions, 55 deletions
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp index 0d351cf..4a091cb 100644 --- a/src/svg/qsvghandler.cpp +++ b/src/svg/qsvghandler.cpp @@ -454,28 +454,6 @@ QSvgAttributes::QSvgAttributes(const QXmlStreamAttributes &xmlAttributes, QSvgHa #ifndef QT_NO_CSSPARSER -static const char * QSvgStyleSelector_nodeString[] = { - "svg", - "g", - "defs", - "switch", - "animation", - "arc", - "circle", - "ellipse", - "image", - "line", - "path", - "polygon", - "polyline", - "rect", - "text", - "textarea", - "tspan", - "use", - "video" -}; - class QSvgStyleSelector : public QCss::StyleSelector { public: @@ -489,7 +467,7 @@ public: inline QString nodeToName(QSvgNode *node) const { - return QLatin1String(QSvgStyleSelector_nodeString[node->type()]); + return node->typeName(); } inline QSvgNode *svgNode(NodePtr node) const diff --git a/src/svg/qsvgnode.cpp b/src/svg/qsvgnode.cpp index f6876c4..e904c25 100644 --- a/src/svg/qsvgnode.cpp +++ b/src/svg/qsvgnode.cpp @@ -366,40 +366,38 @@ QSvgTinyDocument * QSvgNode::document() const QString QSvgNode::typeName() const { - #define stringForType(type) case type: return QStringLiteral(#type); switch (type()) { - stringForType(Doc) - stringForType(Group) - stringForType(Defs) - stringForType(Switch) - stringForType(Animation) - stringForType(Circle) - stringForType(Ellipse) - stringForType(Image) - stringForType(Line) - stringForType(Path) - stringForType(Polygon) - stringForType(Polyline) - stringForType(Rect) - stringForType(Text) - stringForType(Textarea) - stringForType(Tspan) - stringForType(Use) - stringForType(Video) - stringForType(Mask) - stringForType(Symbol) - stringForType(Marker) - stringForType(Pattern) - stringForType(Filter) - stringForType(FeMerge) - stringForType(FeMergenode) - stringForType(FeColormatrix) - stringForType(FeGaussianblur) - stringForType(FeOffset) - stringForType(FeComposite) - stringForType(FeFlood) + case Doc: return QStringLiteral("svg"); + case Group: return QStringLiteral("g"); + case Defs: return QStringLiteral("defs"); + case Switch: return QStringLiteral("switch"); + case Animation: return QStringLiteral("animation"); + case Circle: return QStringLiteral("circle"); + case Ellipse: return QStringLiteral("ellipse"); + case Image: return QStringLiteral("image"); + case Line: return QStringLiteral("line"); + case Path: return QStringLiteral("path"); + case Polygon: return QStringLiteral("polygon"); + case Polyline: return QStringLiteral("polyline"); + case Rect: return QStringLiteral("rect"); + case Text: return QStringLiteral("text"); + case Textarea: return QStringLiteral("textarea"); + case Tspan: return QStringLiteral("tspan"); + case Use: return QStringLiteral("use"); + case Video: return QStringLiteral("video"); + case Mask: return QStringLiteral("mask"); + case Symbol: return QStringLiteral("symbol"); + case Marker: return QStringLiteral("marker"); + case Pattern: return QStringLiteral("pattern"); + case Filter: return QStringLiteral("filter"); + case FeMerge: return QStringLiteral("feMerge"); + case FeMergenode: return QStringLiteral("feMergeNode"); + case FeColormatrix: return QStringLiteral("feColorMatrix"); + case FeGaussianblur: return QStringLiteral("feGaussianBlur"); + case FeOffset: return QStringLiteral("feOffset"); + case FeComposite: return QStringLiteral("feComposite"); + case FeFlood: return QStringLiteral("feFlood"); } - #undef stringForType return QStringLiteral("unknown"); } |