From e439484a453b95e8400899678abe996020c9af37 Mon Sep 17 00:00:00 2001 From: Dave DeLong Date: Fri, 19 Mar 2010 14:19:23 -0600 Subject: Modified the unregister method, since relying on unregistration happening during -dealloc can cause some minor problems (including hotkeys not getting unregistered immediately) --- DDHotKeyCenter.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/DDHotKeyCenter.m b/DDHotKeyCenter.m index dffdced..7fc4af4 100644 --- a/DDHotKeyCenter.m +++ b/DDHotKeyCenter.m @@ -181,12 +181,13 @@ NSUInteger dd_translateModifierFlags(NSUInteger flags); } - (void) unregisterHotKeysMatchingPredicate:(NSPredicate *)predicate { - //when a DDHotKey is deallocated, it unregisters itself - //-hotKeysMatchingPredicate returns an autoreleased set - //so we force sooner deallocation (and unregistering) with a explicit pool + //explicitly unregister the hotkey, since relying on the unregistration in -dealloc can be problematic NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSSet * matches = [self hotKeysMatchingPredicate:predicate]; [_registeredHotKeys minusSet:matches]; + for (DDHotKey * key in matches) { + [key unregisterHotKey]; + } [pool release]; } -- cgit v1.2.3