[iOS] PP: Bookmarks crash fix on unsupported image formats

https://jira.mail.ru/browse/MAPSME-12001
This commit is contained in:
Alexander Boriskov 2019-11-11 14:28:03 +03:00 committed by Aleksey Belousov
parent e7650967bf
commit 41287d7fd3

View file

@ -68,8 +68,8 @@ extension NSMutableAttributedString {
func enumerateAttachments(estimatedWidth: CGFloat) {
enumerateAttribute(.attachment, in: NSMakeRange(0, length), options: []) { (value, range, _) in
if let attachement = value as? NSTextAttachment {
let image = attachement.image(forBounds: attachement.bounds, textContainer: NSTextContainer(), characterIndex: range.location)!
if let attachement = value as? NSTextAttachment,
let image = attachement.image(forBounds: attachement.bounds, textContainer: NSTextContainer(), characterIndex: range.location) {
if image.size.width > estimatedWidth {
let newImage = resizeImage(image: image, scale: estimatedWidth/image.size.width) ?? image
let resizedAttachment = NSTextAttachment()