Fix crash if window removed while fast account switcher is hiding

This commit is contained in:
Shadowfacts 2023-11-18 11:36:59 -05:00
parent 16f6dc84c9
commit 13809b91d1
1 changed files with 6 additions and 2 deletions

View File

@ -166,7 +166,9 @@ class FastAccountSwitcherViewController: UIViewController {
selectionChangedFeedbackGenerator = nil selectionChangedFeedbackGenerator = nil
hide() { hide() {
(self.view.window!.windowScene!.delegate as! MainSceneDelegate).showAddAccount() if let sceneDelegate = self.view.window?.windowScene?.delegate as? MainSceneDelegate {
sceneDelegate.showAddAccount()
}
} }
} else { } else {
let account = UserAccountsManager.shared.accounts[newIndex - 1] let account = UserAccountsManager.shared.accounts[newIndex - 1]
@ -178,7 +180,9 @@ class FastAccountSwitcherViewController: UIViewController {
selectionChangedFeedbackGenerator = nil selectionChangedFeedbackGenerator = nil
hide() { hide() {
(self.view.window!.windowScene!.delegate as! MainSceneDelegate).activateAccount(account, animated: true) if let sceneDelegate = self.view.window?.windowScene?.delegate as? MainSceneDelegate {
sceneDelegate.activateAccount(account, animated: true)
}
} }
} else { } else {
hide() hide()