2
0

Fixed some minor crash cases.

[FIXED]     Crash when changing iCloud store.
[FIXED]     Use main thread when holding down on a user.
This commit is contained in:
Maarten Billemont 2013-08-11 15:30:01 -04:00
parent d583bdfd3c
commit 17bb5706f8
5 changed files with 57 additions and 47 deletions

2
External/Pearl vendored

@ -1 +1 @@
Subproject commit fa4f22d4386d6ffec169b620c722cc7c89aa1715 Subproject commit ed17f53324c5537d70cb08e25b07eb4def2eb9c5

@ -1 +1 @@
Subproject commit 59a0c1e8452ba1094fafdd1d8804a1edfe93347c Subproject commit 4d23a792070c0895c7b2ab0e7ab6a74d4c3a2078

View File

@ -22,6 +22,7 @@
@interface MPLogsViewController : UIViewController @interface MPLogsViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextView *logView; @property (weak, nonatomic) IBOutlet UITextView *logView;
@property (weak, nonatomic) IBOutlet UISegmentedControl *levelControl; @property (weak, nonatomic) IBOutlet UISegmentedControl *levelControl;
@property(nonatomic, strong) PearlAlert *switchCloudStoreProgress;
- (IBAction)action:(id)sender; - (IBAction)action:(id)sender;
- (IBAction)toggleLevelControl:(UISegmentedControl *)sender; - (IBAction)toggleLevelControl:(UISegmentedControl *)sender;
- (IBAction)refresh:(UIBarButtonItem *)sender; - (IBAction)refresh:(UIBarButtonItem *)sender;

View File

@ -21,7 +21,11 @@
#import "MPAppDelegate_Store.h" #import "MPAppDelegate_Store.h"
#import "MPAppDelegate_Key.h" #import "MPAppDelegate_Key.h"
@implementation MPLogsViewController @implementation MPLogsViewController {
PearlAlert *switchCloudStoreProgress;
}
@synthesize switchCloudStoreProgress;
- (void)viewDidLoad { - (void)viewDidLoad {
@ -58,7 +62,10 @@
if (buttonIndex_ == alert.cancelButtonIndex) if (buttonIndex_ == alert.cancelButtonIndex)
return; return;
[self switchCloudStore]; switchCloudStoreProgress = [PearlAlert showActivityWithTitle:@"Enumerating Stores"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
[self switchCloudStore];
});
} cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:[PearlStrings get].commonButtonContinue, nil]; } cancelTitle:[PearlStrings get].commonButtonCancel otherTitles:[PearlStrings get].commonButtonContinue, nil];
} }
} cancelTitle:[PearlStrings get].commonButtonCancel } cancelTitle:[PearlStrings get].commonButtonCancel
@ -80,22 +87,27 @@
if ([[NSFileManager defaultManager] fileExistsAtPath:content.path isDirectory:&directory] && directory) if ([[NSFileManager defaultManager] fileExistsAtPath:content.path isDirectory:&directory] && directory)
[contentNames addObject:[content lastPathComponent]]; [contentNames addObject:[content lastPathComponent]];
[PearlSheet showSheetWithTitle:[[MPiOSAppDelegate get].storeManager valueForKey:@"storeUUID_ThreadSafe"] NSString *storeUUID = [[MPiOSAppDelegate get].storeManager valueForKey:@"storeUUID_ThreadSafe"];
viewStyle:UIActionSheetStyleAutomatic dispatch_async(dispatch_get_main_queue(), ^{
initSheet:^(UIActionSheet *sheet) { [switchCloudStoreProgress cancelAlertAnimated:YES];
for (NSString *contentName in contentNames) {
[sheet addButtonWithTitle:contentName];
}
}
tappedButtonBlock:^(UIActionSheet *sheet, NSInteger buttonIndex) {
if (buttonIndex == sheet.cancelButtonIndex)
return;
[[MPiOSAppDelegate get].storeManager setValue:[contentNames objectAtIndex:(unsigned)buttonIndex] forKey:@"storeUUID"]; [PearlSheet showSheetWithTitle:storeUUID
[[MPiOSAppDelegate get].storeManager reloadStore]; viewStyle:UIActionSheetStyleAutomatic
[[MPiOSAppDelegate get] signOutAnimated:YES]; initSheet:^(UIActionSheet *sheet) {
} for (NSString *contentName in contentNames) {
cancelTitle:[PearlStrings get].commonButtonCancel destructiveTitle:nil otherTitles:nil]; [sheet addButtonWithTitle:contentName];
}
}
tappedButtonBlock:^(UIActionSheet *sheet, NSInteger buttonIndex) {
if (buttonIndex == sheet.cancelButtonIndex)
return;
[[MPiOSAppDelegate get].storeManager setValue:[contentNames objectAtIndex:(unsigned)buttonIndex] forKey:@"storeUUID"];
[[MPiOSAppDelegate get].storeManager reloadStore];
[[MPiOSAppDelegate get] signOutAnimated:YES];
}
cancelTitle:[PearlStrings get].commonButtonCancel destructiveTitle:nil otherTitles:nil];
});
} }
- (IBAction)toggleLevelControl:(UISegmentedControl *)sender { - (IBAction)toggleLevelControl:(UISegmentedControl *)sender {

View File

@ -1006,38 +1006,35 @@
if ([self selectedUserForThread]) if ([self selectedUserForThread])
return; return;
[MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) { NSManagedObjectContext *context = [MPiOSAppDelegate managedObjectContextForMainThreadIfReady];
MPUserEntity *targetedUser = [self userForAvatar:[self findTargetedAvatar] inContext:context]; MPUserEntity *targetedUser = [self userForAvatar:[self findTargetedAvatar] inContext:context];
if (!targetedUser) if (!targetedUser)
return;
[PearlSheet showSheetWithTitle:targetedUser.name
viewStyle:UIActionSheetStyleBlackTranslucent
initSheet:nil tappedButtonBlock:^(UIActionSheet *sheet, NSInteger buttonIndex) {
if (buttonIndex == [sheet cancelButtonIndex])
return; return;
[PearlSheet showSheetWithTitle:targetedUser.name if (buttonIndex == [sheet destructiveButtonIndex]) {
viewStyle:UIActionSheetStyleBlackTranslucent [context deleteObject:targetedUser];
initSheet:nil tappedButtonBlock:^(UIActionSheet *sheet, NSInteger buttonIndex) { [context saveToStore];
if (buttonIndex == [sheet cancelButtonIndex])
return;
if (buttonIndex == [sheet destructiveButtonIndex]) { dispatch_async( dispatch_get_main_queue(), ^{
[context performBlock:^{ [self updateUsers];
[context deleteObject:targetedUser]; } );
[context saveToStore]; return;
}
dispatch_async( dispatch_get_main_queue(), ^{ if (buttonIndex == [sheet firstOtherButtonIndex])
[self updateUsers]; [[MPiOSAppDelegate get] changeMasterPasswordFor:targetedUser saveInContext:context didResetBlock:^{
} ); dispatch_async( dispatch_get_main_queue(), ^{
}]; [[self avatarForUser:targetedUser] setSelected:YES];
return; } );
} }];
} cancelTitle:[PearlStrings get].commonButtonCancel
if (buttonIndex == [sheet firstOtherButtonIndex]) destructiveTitle:@"Delete User" otherTitles:@"Reset Password", nil];
[[MPiOSAppDelegate get] changeMasterPasswordFor:targetedUser saveInContext:context didResetBlock:^{
dispatch_async( dispatch_get_main_queue(), ^{
[[self avatarForUser:targetedUser] setSelected:YES];
} );
}];
} cancelTitle:[PearlStrings get].commonButtonCancel
destructiveTitle:@"Delete User" otherTitles:@"Reset Password", nil];
}];
} }
- (IBAction)facebook:(UIButton *)sender { - (IBAction)facebook:(UIButton *)sender {