From 2e89423a2b3867288ee0b34298221211b42e1189 Mon Sep 17 00:00:00 2001 From: Winnie Quinn Date: Sat, 3 Sep 2022 17:43:16 -0400 Subject: [PATCH] Fix account add crash As reported in Ranchero-Software#3606, it was the case that attempting to add an account could result in a crash. This fixes the problem by retaining the `NSHostingController` that holds the `AddAccountsView` view in a manner similar to how 48138b1bb retained `accountsAddLocalWindowController`. --- .../Accounts/AccountsPreferencesViewController.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift index d1a81e611..307f5b8b5 100644 --- a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift +++ b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift @@ -24,6 +24,7 @@ final class AccountsPreferencesViewController: NSViewController { @IBOutlet weak var deleteButton: NSButton! var addAccountDelegate: AccountsPreferencesAddAccountDelegate? var addAccountWindowController: NSWindowController? + var addAccountsViewController: NSHostingController? private var sortedAccounts = [Account]() @@ -52,6 +53,7 @@ final class AccountsPreferencesViewController: NSViewController { let controller = NSHostingController(rootView: AddAccountsView(delegate: self)) controller.rootView.parent = controller presentAsSheet(controller) + addAccountsViewController = controller } @IBAction func removeAccount(_ sender: Any) {