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

View File

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

View File

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

View File

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