Skip to content

Commit

Permalink
Merge pull request #639 from amarunko/svg-parser-pattern-crash-fix
Browse files Browse the repository at this point in the history
Fix crash in parsing pattern
  • Loading branch information
ystrot authored Nov 28, 2019
2 parents 289c753 + fd899c7 commit 9df164f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Source/svg/SVGParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -465,16 +465,15 @@ open class SVGParser {
if let units = element.allAttributes["patternContentUnits"]?.text, units == "objectBoundingBox" {
contentUserSpace = false
}

var contentNode: Node?
if pattern.children.isEmpty {
if let parentPattern = parentPattern {
contentNode = parentPattern.content
}
} else if pattern.children.count == 1 {
if let shape = try parseNode(pattern.children.first!) as? Shape {
contentNode = shape
}
} else if pattern.children.count == 1,
let shape = try parseNode(pattern.children.first!) as? Shape {
contentNode = shape
} else {
var shapes = [Shape]()
try pattern.children.forEach { indexer in
Expand All @@ -484,7 +483,7 @@ open class SVGParser {
}
contentNode = Group(contents: shapes)
}

return UserSpacePattern(content: contentNode!,
bounds: bounds,
userSpace: userSpace,
Expand Down

0 comments on commit 9df164f

Please sign in to comment.