Skip to content

Commit

Permalink
display(macOS): fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
osy committed Nov 20, 2024
1 parent a3273db commit c4b7c14
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class VMDisplayAppleDisplayWindowController: VMDisplayAppleWindowController {
}

override func windowWillClose(_ notification: Notification) {
if let screenChangedToken = screenChangedToken {
NotificationCenter.default.removeObserver(screenChangedToken)
}
screenChangedToken = nil
super.windowWillClose(notification)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ class VMDisplayQemuMetalWindowController: VMDisplayQemuWindowController {
override func windowWillClose(_ notification: Notification) {
vmDisplay?.removeRenderer(renderer!)
stopAllCapture()
if let screenChangedToken = screenChangedToken {
NotificationCenter.default.removeObserver(screenChangedToken)
}
screenChangedToken = nil
super.windowWillClose(notification)
}
Expand Down

0 comments on commit c4b7c14

Please sign in to comment.