sindresorhus / KeyboardShortcuts

⌨️ Add user-customizable global keyboard shortcuts (hotkeys) to your macOS app in minutes
https://swiftpackageindex.com/sindresorhus/KeyboardShortcuts/documentation/keyboardshortcuts/keyboardshortcuts
MIT License
1.94k stars 181 forks source link

Fixed memory leak in case of NSMenuItem. #154

Closed sonsongithub closed 9 months ago

sonsongithub commented 9 months ago

NSMenuItem has been leaked after calling setShortcuts and KeyboardShortcuts.removeAllHandlers.

The leak is caused by a callback function registered in the notification center that captures an NSMenuItem. I added the code to remove NSMenuItem from notification center explicitly in case of calling setShortcut(nil) to get around this issue.

sindresorhus commented 9 months ago

Thanks :)