Skip to content

Commit

Permalink
fix for a nasty beach ball spinning when switching keyboard layouts i…
Browse files Browse the repository at this point in the history
…n TotalFinder (http://getsatisfaction.com/binaryage/topics/mac_hangs_when_switching_language)

The problem lies in regenerateStringToKeyCodeMapping on first line where transformer is allocated. During the allocation, init is called and previously at that point kTISNotifySelectedKeyboardInputSourceChanged handler was registered. Normally is should not be a problem you say? Well, there are some complex keyboard layouts which somehow generate cascade of kTISNotifySelectedKeyboardInputSourceChanged notifications and system ends up with dozens of registered handlers waiting for next keyboard switch. I didn't investigate this to the core of the problem. But from my observation this affected all keyboard layout which have sub-layouts in System Preferences > Language & Text > Input Sources. For example Chinese, Kotoeri or Hangul.
  • Loading branch information
darwin committed Jun 30, 2010
1 parent a6ec94f commit 1aabc13
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/SRKeyCodeTransformer.m
Expand Up @@ -99,6 +99,8 @@ + (void) initialize;
// generate the string to keycode mapping dict...
stringToKeyCodeDict = [[NSMutableDictionary alloc] init];
[self regenerateStringToKeyCodeMapping];

[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(regenerateStringToKeyCodeMapping) name:(NSString*)kTISNotifySelectedKeyboardInputSourceChanged object:nil];
}

//----------------------------------------------------------
Expand All @@ -125,7 +127,6 @@ - (id)init
{
if((self = [super init]))
{
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadCache:) name:(NSString*)kTISNotifySelectedKeyboardInputSourceChanged object:nil];
}
return self;
}
Expand All @@ -135,7 +136,6 @@ - (id)init
//----------------------------------------------------------
- (void)dealloc
{
[[NSDistributedNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}

Expand Down

0 comments on commit 1aabc13

Please sign in to comment.