From ae416bb604582defc04c3f2f9a343aa499d96767 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 17 Mar 2020 21:44:06 -0400 Subject: [PATCH] Prevent crash if BaseStatusTableViewCell is leaked If prefernces change and the the view controller the cell belongs to is dealloced, the mastodonController will be nil, previously causing a crash. --- Tusker/Views/Status/BaseStatusTableViewCell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tusker/Views/Status/BaseStatusTableViewCell.swift b/Tusker/Views/Status/BaseStatusTableViewCell.swift index fb1a7976..9c55bd0b 100644 --- a/Tusker/Views/Status/BaseStatusTableViewCell.swift +++ b/Tusker/Views/Status/BaseStatusTableViewCell.swift @@ -191,7 +191,7 @@ class BaseStatusTableViewCell: UITableViewCell { } @objc func updateUIForPreferences() { - guard let account = mastodonController.cache.account(for: accountID) else { return } + guard let mastodonController = mastodonController, let account = mastodonController.cache.account(for: accountID) else { return } avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarImageView) displayNameLabel.updateForAccountDisplayName(account: account) attachmentsView.contentHidden = Preferences.shared.blurAllMedia || (mastodonController.cache.status(for: statusID)?.sensitive ?? false)