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
queue:[NSOperationQueue mainQueue] usingBlock:
^(NSNotification *note) {
NSString *key = note.object;
if (!key || [key isEqualToString:NSStringFromSelector( @selector( rememberLogin ) )])
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.dialogStyleHUD.state = [[MPMacConfig get].dialogStyleHUD boolValue]? NSOnState: NSOffState;
if ([note.object isEqual:NSStringFromSelector( @selector(dialogStyleHUD) )]) {
if (![self.passwordWindow.window isVisible])
self.passwordWindow = nil;
else {

View File

@ -64,7 +64,7 @@
[self registerObservers];
[self observeStore];
[self updateFromConfig];
[self updateConfigKey:nil];
[self updatePasswords];
}
@ -175,6 +175,7 @@ referenceSizeForHeaderInSection:(NSInteger)section {
if (controller == _fetchedResultsController) {
[self.passwordCollectionView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.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,8 +312,9 @@ referenceSizeForHeaderInSection:(NSInteger)section {
[[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;
}

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];