MASShortcut icon indicating copy to clipboard operation
MASShortcut copied to clipboard

Event deadlock in MASShortcutView.m

Open dsanghan opened this issue 8 years ago • 2 comments

I'm using the MASShortcutView inside an NSTableView which is inside an NSPopover. The popover autoreleases its memory with a delay on closing it. What this causes is that the MASShortcutView inside the table cell gets deallocated with a delay thereby triggering [self activateEventMonitoring:NO]; with a delay as well. Since the dealloc happens after this delay, and if another NSPopover is opened in the mean time, the [self activateEventMonitoring:YES]; triggers before the dealloc causing the event monitor to be re-registered first and then removed (incorrectly) on the dealloc.

To be clear: Open popover -> Click on an MASShortcutView to trigger recording -> Set the new shortcut -> Close popover -> Open popover -> Click again on an MASShortcutView -> Can't set the new shortcut since the dealloc happens around this time for the old popover.

dsanghan avatar Apr 26 '16 12:04 dsanghan

Thank you for the report! So it should be a counter and methods beginEventMonitoring / endEventMonitoring which stops monitoring when it reaches zero 🤔 Would this help?

shpakovski avatar Apr 27 '16 06:04 shpakovski

Yup. I think that should work. Thanks!

dsanghan avatar Apr 27 '16 09:04 dsanghan