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
@property (weak, nonatomic) IBOutlet UITextView *logView;
@property (weak, nonatomic) IBOutlet UISegmentedControl *levelControl;
@property(nonatomic, strong) PearlAlert *switchCloudStoreProgress;
- (IBAction)action:(id)sender;
- (IBAction)toggleLevelControl:(UISegmentedControl *)sender;
- (IBAction)refresh:(UIBarButtonItem *)sender;

View File

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

View File

@ -1006,38 +1006,35 @@
if ([self selectedUserForThread])
return;
[MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) {
MPUserEntity *targetedUser = [self userForAvatar:[self findTargetedAvatar] inContext:context];
if (!targetedUser)
NSManagedObjectContext *context = [MPiOSAppDelegate managedObjectContextForMainThreadIfReady];
MPUserEntity *targetedUser = [self userForAvatar:[self findTargetedAvatar] inContext:context];
if (!targetedUser)
return;
[PearlSheet showSheetWithTitle:targetedUser.name
viewStyle:UIActionSheetStyleBlackTranslucent
initSheet:nil tappedButtonBlock:^(UIActionSheet *sheet, NSInteger buttonIndex) {
if (buttonIndex == [sheet cancelButtonIndex])
return;
[PearlSheet showSheetWithTitle:targetedUser.name
viewStyle:UIActionSheetStyleBlackTranslucent
initSheet:nil tappedButtonBlock:^(UIActionSheet *sheet, NSInteger buttonIndex) {
if (buttonIndex == [sheet cancelButtonIndex])
return;
if (buttonIndex == [sheet destructiveButtonIndex]) {
[context deleteObject:targetedUser];
[context saveToStore];
if (buttonIndex == [sheet destructiveButtonIndex]) {
[context performBlock:^{
[context deleteObject:targetedUser];
[context saveToStore];
dispatch_async( dispatch_get_main_queue(), ^{
[self updateUsers];
} );
return;
}
dispatch_async( dispatch_get_main_queue(), ^{
[self updateUsers];
} );
}];
return;
}
if (buttonIndex == [sheet firstOtherButtonIndex])
[[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];
}];
if (buttonIndex == [sheet firstOtherButtonIndex])
[[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 {