Skip to content

Commit

Permalink
macOS: weak self for event monitor to avoid retain cycle for controllers
Browse files Browse the repository at this point in the history
Fixes ghostty-org#3219

We were holding a reference cycle to the base terminal controller. This
was preventing the window from ever being fully deallocated.
  • Loading branch information
mitchellh authored and otherJL0 committed Jan 1, 2025
1 parent c2223cd commit 3cb1975
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions macos/Sources/Features/Terminal/BaseTerminalController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ class BaseTerminalController: NSWindowController,
// Listen for local events that we need to know of outside of
// single surface handlers.
self.eventMonitor = NSEvent.addLocalMonitorForEvents(
matching: [.flagsChanged],
handler: localEventHandler)
matching: [.flagsChanged]
) { [weak self] event in self?.localEventHandler(event) }
}

deinit {
Expand Down Expand Up @@ -160,7 +160,7 @@ class BaseTerminalController: NSWindowController,
}

// MARK: Notifications

@objc private func didChangeScreenParametersNotification(_ notification: Notification) {
// 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.
Expand Down

0 comments on commit 3cb1975

Please sign in to comment.