1
1
mirror of https://github.com/exyte/Macaw.git synced 2024-11-04 00:39:57 +03:00

Merge pull request #639 from amarunko/svg-parser-pattern-crash-fix

Fix crash in parsing pattern
This commit is contained in:
Yuri Strot 2019-11-28 14:20:56 +07:00 committed by GitHub
commit 9df164f79d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
@ -484,7 +483,7 @@ open class SVGParser {
}
contentNode = Group(contents: shapes)
}
return UserSpacePattern(content: contentNode!,
bounds: bounds,
userSpace: userSpace,