crashfix: crash while accessing image property

assert on blind cast

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent 2eaaba9082
commit bb8f6c1b73

@ -2202,10 +2202,17 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
if ([[messageItem media] isKindOfClass:[TSPhotoAdapter class]]) {
TSPhotoAdapter *messageMedia = (TSPhotoAdapter *)[messageItem media];
UIImage *tappedImage = ((UIImageView *)[messageMedia mediaView]).image;
UIView *mediaView = [messageMedia mediaView];
if (![mediaView isKindOfClass:[UIImageView class]]) {
OWSFail(@"unexpected mediaView of type: %@", [mediaView class]);
return;
}
UIImageView *imageView = (UIImageView *)mediaView;
UIImage *tappedImage = imageView.image;
if (tappedImage == nil) {
DDLogWarn(@"tapped TSPhotoAdapter with nil image");
} else {
return;
}
UIWindow *window = [UIApplication sharedApplication].keyWindow;
JSQMessagesCollectionViewCell *cell
= (JSQMessagesCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
@ -2214,14 +2221,13 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
__block TSAttachment *attachment = nil;
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
attachment = [TSAttachment fetchObjectWithUniqueID:messageMedia.attachmentId
transaction:transaction];
attachment =
[TSAttachment fetchObjectWithUniqueID:messageMedia.attachmentId transaction:transaction];
}];
if ([attachment isKindOfClass:[TSAttachmentStream class]]) {
TSAttachmentStream *attStream = (TSAttachmentStream *)attachment;
FullImageViewController *vc =
[[FullImageViewController alloc] initWithAttachment:attStream
FullImageViewController *vc = [[FullImageViewController alloc] initWithAttachment:attStream
fromRect:convertedRect
forInteraction:interaction
messageItem:messageItem
@ -2229,7 +2235,6 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
[vc presentFromViewController:self];
}
}
} else if ([[messageItem media] isKindOfClass:[TSAnimatedAdapter class]]) {
// Show animated image full-screen
TSAnimatedAdapter *messageMedia = (TSAnimatedAdapter *)[messageItem media];

Loading…
Cancel
Save