Remove references to windows when they close so that they will deallocate.

This commit is contained in:
Maurice Parker 2020-03-02 18:06:55 -08:00
parent b6ff9e8ff4
commit e920235038
2 changed files with 8 additions and 0 deletions

View File

@ -383,6 +383,12 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
}
}
func removeMainWindow(_ windowController: MainWindowController) {
if let index = mainWindowControllers.firstIndex(of: windowController) {
mainWindowControllers.remove(at: index)
}
}
// MARK: NSUserInterfaceValidations
func validateUserInterfaceItem(_ item: NSValidatedUserInterfaceItem) -> Bool {
if shuttingDown {

View File

@ -462,7 +462,9 @@ extension MainWindowController: NSWindowDelegate {
}
func windowWillClose(_ notification: Notification) {
// TODO: now that we are deallocating main window controllers, the media playback stop can probably be removed
detailViewController?.stopMediaPlayback()
appDelegate.removeMainWindow(self)
}
}