Fixes crash when attempting to use invalid clipboard image when changing game artwork

This commit is contained in:
Riley Testut 2017-12-21 15:39:35 -06:00
parent a371bb71a9
commit 5939e20399
2 changed files with 8 additions and 10 deletions

View File

@ -526,11 +526,10 @@ extension GameCollectionViewController: ImportControllerDelegate
{ {
let imageData = try Data(contentsOf: url) let imageData = try Data(contentsOf: url)
if let image = UIImage(data: imageData) if
{ let image = UIImage(data: imageData),
let resizedImage = image.resizing(toFit: CGSize(width: 300, height: 300)) let resizedImage = image.resizing(toFit: CGSize(width: 300, height: 300)),
let resizedData = UIImageJPEGRepresentation(resizedImage, 0.85)
if let resizedData = UIImageJPEGRepresentation(resizedImage, 0.85)
{ {
let destinationURL = DatabaseManager.artworkURL(for: game) let destinationURL = DatabaseManager.artworkURL(for: game)
try resizedData.write(to: destinationURL, options: .atomic) try resizedData.write(to: destinationURL, options: .atomic)
@ -538,7 +537,6 @@ extension GameCollectionViewController: ImportControllerDelegate
imageURL = destinationURL imageURL = destinationURL
} }
} }
}
catch catch
{ {
errors.append(error) errors.append(error)

2
External/Roxas vendored

@ -1 +1 @@
Subproject commit 902035729a2d93099f07d63af2f77f6e326ebfec Subproject commit 97b3a7ab05ee320d3c96eadc3cc69c38d10ec206