2
0

Fix infinite loop when enabling iCloud.

[FIXED]     When enabling iCloud and setting the local user defaults, we re-started enabling iCloud and updating local user defaults.
This commit is contained in:
Maarten Billemont 2014-06-05 21:43:06 -04:00
parent db55634ab2
commit 789aa26066
4 changed files with 35 additions and 33 deletions

View File

@ -290,12 +290,12 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
[[NSNotificationCenter defaultCenter] addObserverForName:MPCheckConfigNotification object:nil [[NSNotificationCenter defaultCenter] addObserverForName:MPCheckConfigNotification object:nil
queue:[NSOperationQueue mainQueue] usingBlock: queue:[NSOperationQueue mainQueue] usingBlock:
^(NSNotification *note) { ^(NSNotification *note) {
NSString *key = note.object;
if (!key || [key isEqualToString:NSStringFromSelector( @selector( rememberLogin ) )])
self.rememberPasswordItem.state = [[MPConfig get].rememberLogin boolValue]? NSOnState: NSOffState; self.rememberPasswordItem.state = [[MPConfig get].rememberLogin boolValue]? NSOnState: NSOffState;
self.savePasswordItem.state = [[MPMacAppDelegate get] activeUserForMainThread].saveKey? NSOnState: NSOffState; if (!key || [key isEqualToString:NSStringFromSelector( @selector( dialogStyleHUD ) )]) {
self.dialogStyleRegular.state = ![[MPMacConfig get].dialogStyleHUD boolValue]? NSOnState: NSOffState; self.dialogStyleRegular.state = ![[MPMacConfig get].dialogStyleHUD boolValue]? NSOnState: NSOffState;
self.dialogStyleHUD.state = [[MPMacConfig get].dialogStyleHUD boolValue]? NSOnState: NSOffState; self.dialogStyleHUD.state = [[MPMacConfig get].dialogStyleHUD boolValue]? NSOnState: NSOffState;
if ([note.object isEqual:NSStringFromSelector( @selector(dialogStyleHUD) )]) {
if (![self.passwordWindow.window isVisible]) if (![self.passwordWindow.window isVisible])
self.passwordWindow = nil; self.passwordWindow = nil;
else { else {

View File

@ -64,7 +64,7 @@
[self registerObservers]; [self registerObservers];
[self observeStore]; [self observeStore];
[self updateFromConfig]; [self updateConfigKey:nil];
[self updatePasswords]; [self updatePasswords];
} }
@ -175,6 +175,7 @@ referenceSizeForHeaderInSection:(NSInteger)section {
if (controller == _fetchedResultsController) { if (controller == _fetchedResultsController) {
[self.passwordCollectionView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section]]; [self.passwordCollectionView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section]];
if (![newIndexPath isEqual:indexPath])
[self.passwordCollectionView reloadSections:[NSIndexSet indexSetWithIndex:newIndexPath.section]]; [self.passwordCollectionView reloadSections:[NSIndexSet indexSetWithIndex:newIndexPath.section]];
} }
} }
@ -267,9 +268,9 @@ referenceSizeForHeaderInSection:(NSInteger)section {
}]; }];
}], }],
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
addObserverForName:MPCheckConfigNotification object:nil addObserverForName:MPCheckConfigNotification object:nil queue:[NSOperationQueue mainQueue]
queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) { usingBlock:^(NSNotification *note) {
[self updateFromConfig]; [self updateConfigKey:note.object];
}], }],
]; ];
} }
@ -311,8 +312,9 @@ referenceSizeForHeaderInSection:(NSInteger)section {
[[NSNotificationCenter defaultCenter] removeObserver:_storeObserver]; [[NSNotificationCenter defaultCenter] removeObserver:_storeObserver];
} }
- (void)updateFromConfig { - (void)updateConfigKey:(NSString *)key {
if (!key || [key isEqualToString:NSStringFromSelector( @selector(dictationSearch) )])
self.passwordsSearchBar.keyboardType = [[MPiOSConfig get].dictationSearch boolValue]? UIKeyboardTypeDefault: UIKeyboardTypeURL; self.passwordsSearchBar.keyboardType = [[MPiOSConfig get].dictationSearch boolValue]? UIKeyboardTypeDefault: UIKeyboardTypeURL;
} }

View File

@ -757,34 +757,34 @@ typedef NS_ENUM(NSUInteger, MPActiveUserState) {
case MPActiveUserStateLogin: { case MPActiveUserStateLogin: {
dbg(@"activeUserState -> login"); dbg(@"activeUserState -> login");
self.entryLabel.text = strl( @"Enter your master password:" ); self.entryLabel.text = strl( @"Enter your master password:" );
self.entryField.text = nil;
self.entryField.secureTextEntry = YES; self.entryField.secureTextEntry = YES;
self.entryField.autocapitalizationType = UITextAutocapitalizationTypeNone; self.entryField.autocapitalizationType = UITextAutocapitalizationTypeNone;
self.entryField.text = nil;
break; break;
} }
case MPActiveUserStateUserName: { case MPActiveUserStateUserName: {
dbg(@"activeUserState -> userName"); dbg(@"activeUserState -> userName");
self.entryLabel.text = strl( @"Enter your full name:" ); self.entryLabel.text = strl( @"Enter your full name:" );
self.entryField.text = nil;
self.entryField.secureTextEntry = NO; self.entryField.secureTextEntry = NO;
self.entryField.autocapitalizationType = UITextAutocapitalizationTypeWords; self.entryField.autocapitalizationType = UITextAutocapitalizationTypeWords;
self.entryField.text = nil;
break; break;
} }
case MPActiveUserStateMasterPasswordChoice: { case MPActiveUserStateMasterPasswordChoice: {
dbg(@"activeUserState -> masterPasswordChoice"); dbg(@"activeUserState -> masterPasswordChoice");
self.entryLabel.text = strl( @"Choose your master password:" ); self.entryLabel.text = strl( @"Choose your master password:" );
self.entryField.text = nil;
self.entryField.secureTextEntry = YES; self.entryField.secureTextEntry = YES;
self.entryField.autocapitalizationType = UITextAutocapitalizationTypeNone; self.entryField.autocapitalizationType = UITextAutocapitalizationTypeNone;
self.entryField.text = nil;
break; break;
} }
case MPActiveUserStateMasterPasswordConfirmation: { case MPActiveUserStateMasterPasswordConfirmation: {
dbg(@"activeUserState -> masterPasswordConfirmation"); dbg(@"activeUserState -> masterPasswordConfirmation");
_masterPasswordChoice = self.entryField.text; _masterPasswordChoice = self.entryField.text;
self.entryLabel.text = strl( @"Confirm your master password:" ); self.entryLabel.text = strl( @"Confirm your master password:" );
self.entryField.text = nil;
self.entryField.secureTextEntry = YES; self.entryField.secureTextEntry = YES;
self.entryField.autocapitalizationType = UITextAutocapitalizationTypeNone; self.entryField.autocapitalizationType = UITextAutocapitalizationTypeNone;
self.entryField.text = nil;
break; break;
} }
case MPActiveUserStateMinimized: case MPActiveUserStateMinimized:

View File

@ -93,17 +93,17 @@
err( @"During Analytics Setup: %@", exception ); err( @"During Analytics Setup: %@", exception );
} }
@try { @try {
[[NSNotificationCenter defaultCenter] addObserverForName:MPCheckConfigNotification object:nil queue:nil usingBlock: [[NSNotificationCenter defaultCenter] addObserverForName:MPCheckConfigNotification object:nil queue:[NSOperationQueue mainQueue]
^(NSNotification *note) { usingBlock:^(NSNotification *note) {
[self updateFromConfig]; [self updateConfigKey:note.object];
}]; }];
[[NSNotificationCenter defaultCenter] addObserverForName:kIASKAppSettingChanged object:nil queue:nil usingBlock: [[NSNotificationCenter defaultCenter] addObserverForName:kIASKAppSettingChanged object:nil queue:nil usingBlock:
^(NSNotification *note) { ^(NSNotification *note) {
[[NSNotificationCenter defaultCenter] postNotificationName:MPCheckConfigNotification object:note userInfo:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:MPCheckConfigNotification object:note.object];
}]; }];
[[NSNotificationCenter defaultCenter] addObserverForName:NSUserDefaultsDidChangeNotification object:nil queue:nil usingBlock: [[NSNotificationCenter defaultCenter] addObserverForName:NSUserDefaultsDidChangeNotification object:nil queue:nil usingBlock:
^(NSNotification *note) { ^(NSNotification *note) {
[[NSNotificationCenter defaultCenter] postNotificationName:MPCheckConfigNotification object:note userInfo:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:MPCheckConfigNotification object:nil];
}]; }];
#ifdef ADHOC #ifdef ADHOC
@ -292,7 +292,7 @@
- (void)applicationDidBecomeActive:(UIApplication *)application { - (void)applicationDidBecomeActive:(UIApplication *)application {
inf( @"Re-activated" ); inf( @"Re-activated" );
[[NSNotificationCenter defaultCenter] postNotificationName:MPCheckConfigNotification object:application]; [[NSNotificationCenter defaultCenter] postNotificationName:MPCheckConfigNotification object:nil];
[super applicationDidBecomeActive:application]; [super applicationDidBecomeActive:application];
} }
@ -475,7 +475,7 @@
[[NSNotificationCenter defaultCenter] postNotificationName:MPCheckConfigNotification object:NSStringFromSelector( configKey )]; [[NSNotificationCenter defaultCenter] postNotificationName:MPCheckConfigNotification object:NSStringFromSelector( configKey )];
} }
- (void)updateFromConfig { - (void)updateConfigKey:(NSString *)key {
// iCloud enabled / disabled // iCloud enabled / disabled
BOOL iCloudEnabled = [[MPiOSConfig get].iCloudEnabled boolValue]; BOOL iCloudEnabled = [[MPiOSConfig get].iCloudEnabled boolValue];