From f9a62ec3f333a72e5b73d6b1f3f8419be012be2f Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 25 Jan 2020 22:03:21 -0500 Subject: [PATCH] Fix crash when tapping unloaded image attachment --- Tusker/TuskerNavigationDelegate.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tusker/TuskerNavigationDelegate.swift b/Tusker/TuskerNavigationDelegate.swift index fe3671ff..04a0dc02 100644 --- a/Tusker/TuskerNavigationDelegate.swift +++ b/Tusker/TuskerNavigationDelegate.swift @@ -148,7 +148,7 @@ extension TuskerNavigationDelegate where Self: UIViewController { } private func sourceViewInfo(_ sourceView: UIImageView?) -> LargeImageViewController.SourceInfo? { - guard let sourceView = sourceView else { return nil } + guard let sourceView = sourceView, let image = sourceView.image else { return nil } var sourceFrame = sourceView.convert(sourceView.bounds, to: view) if let scrollView = view as? UIScrollView { @@ -159,7 +159,7 @@ extension TuskerNavigationDelegate where Self: UIViewController { let y = sourceFrame.minY * scale - scrollView.contentOffset.y + scrollView.frame.minY sourceFrame = CGRect(x: x, y: y, width: width, height: height) } - return (image: sourceView.image!, frame: sourceFrame, cornerRadius: sourceView.layer.cornerRadius) + return (image: image, frame: sourceFrame, cornerRadius: sourceView.layer.cornerRadius) } func largeImage(_ image: UIImage, description: String?, sourceView: UIImageView) -> LargeImageViewController {