Skip to content

Commit

Permalink
Don't forget to remove the notification observer.
Browse files Browse the repository at this point in the history
  • Loading branch information
lapcat committed Oct 9, 2017
1 parent a79cac9 commit 7bc96b5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion source/LicenseWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ class LicenseWindowController {
window.center() // Wait until after makeKeyAndOrderFront so the window sizes properly first

licenseWindow = window
NotificationCenter.default.addObserver(forName:NSWindow.willCloseNotification, object:licenseWindow, queue:nil, using:{_ in

var observer:NSObjectProtocol?
observer = NotificationCenter.default.addObserver(forName:NSWindow.willCloseNotification, object:licenseWindow, queue:nil, using:{_ in
if let token = observer {
NotificationCenter.default.removeObserver(token)
}
licenseWindow = nil
})
}
Expand Down

0 comments on commit 7bc96b5

Please sign in to comment.