diff --git a/Platform/macOS/Display/VMDisplayAppleDisplayWindowController.swift b/Platform/macOS/Display/VMDisplayAppleDisplayWindowController.swift index 678d98b5a..3650e470d 100644 --- a/Platform/macOS/Display/VMDisplayAppleDisplayWindowController.swift +++ b/Platform/macOS/Display/VMDisplayAppleDisplayWindowController.swift @@ -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) } diff --git a/Platform/macOS/Display/VMDisplayQemuMetalWindowController.swift b/Platform/macOS/Display/VMDisplayQemuMetalWindowController.swift index 9c346b992..5102d6ba7 100644 --- a/Platform/macOS/Display/VMDisplayQemuMetalWindowController.swift +++ b/Platform/macOS/Display/VMDisplayQemuMetalWindowController.swift @@ -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) }