fix(macos): retain MainWindowController so the client stays alive
The main window controller was created as a local variable in ConnectWindowController.authSucceeded and never retained — ARC deallocated it immediately, which destroyed the VoiceCatClient (connection silently dropped), nil'd every button's weak target (clicks did nothing), and killed event delivery (channel list, messages, voice never worked). Symptom: TOFU (in the retained connect controller) worked, but everything in the main window was a zombie shell. Fix: store the MainWindowController in a new field on ConnectWindowController (which AppDelegate retains for the app's lifetime). Also add NSLog diagnostics in deinit/bootstrap/handleEvent so lifecycle and event delivery are observable from the terminal or Console.app.
This commit is contained in:
@@ -18,6 +18,7 @@ final class ConnectWindowController: NSWindowController, NSWindowDelegate {
|
||||
private var servers: [SavedServer] = ServerListStore.load()
|
||||
private var client: VoiceCatClient?
|
||||
private var identityDialogShown = false
|
||||
private var mainWindowController: MainWindowController?
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
@@ -298,6 +299,7 @@ final class ConnectWindowController: NSWindowController, NSWindowDelegate {
|
||||
private func authSucceeded(client: VoiceCatClient, selfUserId: UInt32, nickname: String) {
|
||||
client.onEvent = nil
|
||||
let mainWC = MainWindowController(client: client, selfUserId: selfUserId, nickname: nickname)
|
||||
self.mainWindowController = mainWC
|
||||
mainWC.showWindow(nil)
|
||||
self.client = nil
|
||||
close()
|
||||
|
||||
Reference in New Issue
Block a user