macOS: weak self for event monitor to avoid retain cycle for controllers (#4128)

Fixes #3219

We were holding a reference cycle to the base terminal controller. This
was preventing the window from ever being fully deallocated.
pull/3460/head
Mitchell Hashimoto 2024-12-30 13:49:36 -08:00 committed by GitHub
commit d512f56005
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -111,8 +111,8 @@ class BaseTerminalController: NSWindowController,
// Listen for local events that we need to know of outside of // Listen for local events that we need to know of outside of
// single surface handlers. // single surface handlers.
self.eventMonitor = NSEvent.addLocalMonitorForEvents( self.eventMonitor = NSEvent.addLocalMonitorForEvents(
matching: [.flagsChanged], matching: [.flagsChanged]
handler: localEventHandler) ) { [weak self] event in self?.localEventHandler(event) }
} }
deinit { deinit {
@ -160,7 +160,7 @@ class BaseTerminalController: NSWindowController,
} }
// MARK: Notifications // MARK: Notifications
@objc private func didChangeScreenParametersNotification(_ notification: Notification) { @objc private func didChangeScreenParametersNotification(_ notification: Notification) {
// If we have a window that is visible and it is outside the bounds of the // If we have a window that is visible and it is outside the bounds of the
// screen then we clamp it back to within the screen. // screen then we clamp it back to within the screen.