1
Fork 0

Protect against some missing keys

This commit is contained in:
Joshua Goins 2022-05-09 20:46:59 -04:00
parent 78c36c9acf
commit 50d532aac9

View file

@ -410,15 +410,19 @@ class Document: NSDocument {
info.videoFrame = parsePairString(frameSize)! info.videoFrame = parsePairString(frameSize)!
let colorProfileClassKey = dict["colorProfile"] let colorProfileClassKey = dict["colorProfile"]
let colorProfileClassID = getClassID(id: colorProfileClassKey) if colorProfileClassKey != nil {
let colorProfile = objectsArray[colorProfileClassID] as! NSDictionary let colorProfileClassID = getClassID(id: colorProfileClassKey)
let colorProfile = objectsArray[colorProfileClassID] as! NSDictionary
let colorProfileNameClassKey = colorProfile["SiColorProfileArchiveICCNameKey"] let colorProfileNameClassKey = colorProfile["SiColorProfileArchiveICCNameKey"]
let colorProfileNameClassID = getClassID(id: colorProfileNameClassKey) let colorProfileNameClassID = getClassID(id: colorProfileNameClassKey)
let colorProfileName = objectsArray[colorProfileNameClassID] as! NSString let colorProfileName = objectsArray[colorProfileNameClassID] as! NSString
// we only support the basic "Display P3" color space... does Procreate actually store the ICC data?? // we only support the basic "Display P3" color space... does Procreate actually store the ICC data??
if colorProfileName == "Display P3" { if colorProfileName == "Display P3" {
info.colorSpace = CGColorSpace(name: CGColorSpace.displayP3)!
}
} else {
info.colorSpace = CGColorSpace(name: CGColorSpace.displayP3)! info.colorSpace = CGColorSpace(name: CGColorSpace.displayP3)!
} }
@ -448,11 +452,13 @@ class Document: NSDocument {
} }
let authorClassKey = dict[AuthorNameKey] let authorClassKey = dict[AuthorNameKey]
let authorClassID = getClassID(id: authorClassKey) if authorClassKey != nil {
let authorString = objectsArray[authorClassID] as! String let authorClassID = getClassID(id: authorClassKey)
let authorString = objectsArray[authorClassID] as! String
if authorString != "$null" { if authorString != "$null" {
info.authorName = authorString info.authorName = authorString
}
} }
let sizeClassKey = dict[SizeKey] let sizeClassKey = dict[SizeKey]