Fixed potential crashed due to rare nil values at checkpoints.
[FIXED] Avoid nil values at checkpoints since they will cause crashes.
This commit is contained in:
parent
0a5329fe17
commit
2d8146edbd
@ -74,7 +74,7 @@ static NSDictionary *keyQuery(MPUserEntity *user) {
|
|||||||
- (BOOL)signInAsUser:(MPUserEntity *)user saveInContext:(NSManagedObjectContext *)moc usingMasterPassword:(NSString *)password {
|
- (BOOL)signInAsUser:(MPUserEntity *)user saveInContext:(NSManagedObjectContext *)moc usingMasterPassword:(NSString *)password {
|
||||||
|
|
||||||
if (password)
|
if (password)
|
||||||
NSAssert(![NSThread isMainThread], @"Computing key must not happen from the main thread.");
|
NSAssert(![NSThread isMainThread], @"Computing key must not happen from the main thread.");
|
||||||
|
|
||||||
MPKey *tryKey = nil;
|
MPKey *tryKey = nil;
|
||||||
|
|
||||||
|
@ -105,14 +105,15 @@ PearlAssociatedObjectProperty(NSManagedObjectContext*, MainManagedObjectContext,
|
|||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillTerminateNotification object:[UIApplication sharedApplication]
|
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillTerminateNotification object:[UIApplication sharedApplication]
|
||||||
queue:[NSOperationQueue mainQueue] usingBlock:
|
queue:[NSOperationQueue mainQueue] usingBlock:
|
||||||
^(NSNotification *note) {
|
^(NSNotification *note) {
|
||||||
[[self mainManagedObjectContext] saveToStore];
|
[[self mainManagedObjectContext] saveToStore];
|
||||||
}];
|
}];
|
||||||
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillResignActiveNotification object:[UIApplication sharedApplication]
|
[[NSNotificationCenter defaultCenter]
|
||||||
queue:[NSOperationQueue mainQueue] usingBlock:
|
addObserverForName:UIApplicationWillResignActiveNotification object:[UIApplication sharedApplication]
|
||||||
^(NSNotification *note) {
|
queue:[NSOperationQueue mainQueue] usingBlock:
|
||||||
[[self mainManagedObjectContext] saveToStore];
|
^(NSNotification *note) {
|
||||||
}];
|
[[self mainManagedObjectContext] saveToStore];
|
||||||
|
}];
|
||||||
#else
|
#else
|
||||||
[[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationWillTerminateNotification object:NSApp
|
[[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationWillTerminateNotification object:NSApp
|
||||||
queue:[NSOperationQueue mainQueue] usingBlock:
|
queue:[NSOperationQueue mainQueue] usingBlock:
|
||||||
@ -374,7 +375,7 @@ PearlAssociatedObjectProperty(NSManagedObjectContext*, MainManagedObjectContext,
|
|||||||
err(@"[StoreManager] ERROR: cause=%d, context=%@, error=%@", cause, context, error);
|
err(@"[StoreManager] ERROR: cause=%d, context=%@, error=%@", cause, context, error);
|
||||||
MPCheckpoint( MPCheckpointMPErrorUbiquity, @{
|
MPCheckpoint( MPCheckpointMPErrorUbiquity, @{
|
||||||
@"cause" : @(cause),
|
@"cause" : @(cause),
|
||||||
@"error.domain" : error.domain,
|
@"error.domain" : NilToNSNull(error.domain),
|
||||||
@"error.code" : @(error.code)
|
@"error.code" : @(error.code)
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
@ -413,7 +414,8 @@ PearlAssociatedObjectProperty(NSManagedObjectContext*, MainManagedObjectContext,
|
|||||||
|
|
||||||
NSManagedObjectID *elementOID = [element objectID];
|
NSManagedObjectID *elementOID = [element objectID];
|
||||||
dispatch_async( dispatch_get_main_queue(), ^{
|
dispatch_async( dispatch_get_main_queue(), ^{
|
||||||
completion( (MPElementEntity *)[[MPAppDelegate_Shared managedObjectContextForMainThreadIfReady] objectRegisteredForID:elementOID] );
|
completion(
|
||||||
|
(MPElementEntity *)[[MPAppDelegate_Shared managedObjectContextForMainThreadIfReady] objectRegisteredForID:elementOID] );
|
||||||
} );
|
} );
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ forRowAtIndexPath:(NSIndexPath *)indexPath {
|
|||||||
[context saveToStore];
|
[context saveToStore];
|
||||||
|
|
||||||
MPCheckpoint( MPCheckpointDeleteElement, @{
|
MPCheckpoint( MPCheckpointDeleteElement, @{
|
||||||
@"type" : element.typeName,
|
@"type" : NilToNSNull(element.typeName),
|
||||||
@"version" : @(element.version)
|
@"version" : @(element.version)
|
||||||
} );
|
} );
|
||||||
}];
|
}];
|
||||||
|
@ -319,7 +319,7 @@
|
|||||||
- (void)setHelpChapter:(NSString *)chapter {
|
- (void)setHelpChapter:(NSString *)chapter {
|
||||||
|
|
||||||
MPCheckpoint( MPCheckpointHelpChapter, @{
|
MPCheckpoint( MPCheckpointHelpChapter, @{
|
||||||
@"chapter" : chapter
|
@"chapter" : NilToNSNull(chapter)
|
||||||
} );
|
} );
|
||||||
|
|
||||||
dispatch_async( dispatch_get_main_queue(), ^{
|
dispatch_async( dispatch_get_main_queue(), ^{
|
||||||
@ -479,7 +479,7 @@
|
|||||||
[self showContentTip:@"Copied!" withIcon:nil];
|
[self showContentTip:@"Copied!" withIcon:nil];
|
||||||
|
|
||||||
MPCheckpoint( MPCheckpointCopyToPasteboard, @{
|
MPCheckpoint( MPCheckpointCopyToPasteboard, @{
|
||||||
@"type" : activeElement.typeName,
|
@"type" : NilToNSNull(activeElement.typeName),
|
||||||
@"version" : @(activeElement.version),
|
@"version" : @(activeElement.version),
|
||||||
@"emergency" : @NO
|
@"emergency" : @NO
|
||||||
} );
|
} );
|
||||||
@ -497,7 +497,7 @@
|
|||||||
[self showLoginNameTip:@"Copied!"];
|
[self showLoginNameTip:@"Copied!"];
|
||||||
|
|
||||||
MPCheckpoint( MPCheckpointCopyLoginNameToPasteboard, @{
|
MPCheckpoint( MPCheckpointCopyLoginNameToPasteboard, @{
|
||||||
@"type" : activeElement.typeName,
|
@"type" : NilToNSNull(activeElement.typeName),
|
||||||
@"version" : @(activeElement.version)
|
@"version" : @(activeElement.version)
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
@ -521,7 +521,7 @@
|
|||||||
++activeGeneratedElement.counter;
|
++activeGeneratedElement.counter;
|
||||||
|
|
||||||
MPCheckpoint( MPCheckpointIncrementPasswordCounter, @{
|
MPCheckpoint( MPCheckpointIncrementPasswordCounter, @{
|
||||||
@"type" : activeGeneratedElement.typeName,
|
@"type" : NilToNSNull(activeGeneratedElement.typeName),
|
||||||
@"version" : @(activeGeneratedElement.version),
|
@"version" : @(activeGeneratedElement.version),
|
||||||
@"counter" : @(activeGeneratedElement.counter)
|
@"counter" : @(activeGeneratedElement.counter)
|
||||||
} );
|
} );
|
||||||
@ -553,7 +553,7 @@
|
|||||||
((MPElementGeneratedEntity *)activeElement_).counter = 1;
|
((MPElementGeneratedEntity *)activeElement_).counter = 1;
|
||||||
|
|
||||||
MPCheckpoint( MPCheckpointResetPasswordCounter, @{
|
MPCheckpoint( MPCheckpointResetPasswordCounter, @{
|
||||||
@"type" : activeElement_.typeName,
|
@"type" : NilToNSNull(activeElement_.typeName),
|
||||||
@"version" : @(activeElement_.version)
|
@"version" : @(activeElement_.version)
|
||||||
} );
|
} );
|
||||||
return YES;
|
return YES;
|
||||||
@ -574,7 +574,7 @@
|
|||||||
[self.loginNameField becomeFirstResponder];
|
[self.loginNameField becomeFirstResponder];
|
||||||
|
|
||||||
MPCheckpoint( MPCheckpointEditLoginName, @{
|
MPCheckpoint( MPCheckpointEditLoginName, @{
|
||||||
@"type" : activeElement.typeName,
|
@"type" : NilToNSNull(activeElement.typeName),
|
||||||
@"version" : @(activeElement.version)
|
@"version" : @(activeElement.version)
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
@ -601,7 +601,7 @@
|
|||||||
NSString *oldPassword = [activeElement.content description];
|
NSString *oldPassword = [activeElement.content description];
|
||||||
if (!task( activeElement, context ))
|
if (!task( activeElement, context ))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
activeElement = [self activeElementInContext:context];
|
activeElement = [self activeElementInContext:context];
|
||||||
NSString *newPassword = [activeElement.content description];
|
NSString *newPassword = [activeElement.content description];
|
||||||
|
|
||||||
@ -655,7 +655,7 @@
|
|||||||
[self.contentField becomeFirstResponder];
|
[self.contentField becomeFirstResponder];
|
||||||
|
|
||||||
MPCheckpoint( MPCheckpointEditPassword, @{
|
MPCheckpoint( MPCheckpointEditPassword, @{
|
||||||
@"type" : activeElement.typeName,
|
@"type" : NilToNSNull(activeElement.typeName),
|
||||||
@"version" : @(activeElement.version)
|
@"version" : @(activeElement.version)
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
@ -680,7 +680,7 @@
|
|||||||
[activeElement_ migrateExplicitly:YES];
|
[activeElement_ migrateExplicitly:YES];
|
||||||
|
|
||||||
MPCheckpoint( MPCheckpointExplicitMigration, @{
|
MPCheckpoint( MPCheckpointExplicitMigration, @{
|
||||||
@"type" : activeElement_.typeName,
|
@"type" : NilToNSNull(activeElement_.typeName),
|
||||||
@"version" : @(activeElement_.version)
|
@"version" : @(activeElement_.version)
|
||||||
} );
|
} );
|
||||||
return YES;
|
return YES;
|
||||||
@ -831,11 +831,11 @@
|
|||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
MPCheckpoint( MPCheckpointUseType, @{
|
MPCheckpoint( MPCheckpointUseType, @{
|
||||||
@"type" : element.typeName,
|
@"type" : NilToNSNull(element.typeName),
|
||||||
@"version" : @(element.version)
|
@"version" : @(element.version)
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
[self.searchDisplayController setActive:NO animated:YES];
|
[self.searchDisplayController setActive:NO animated:YES];
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
// Copyright (c) 2012 Lyndir. All rights reserved.
|
// Copyright (c) 2012 Lyndir. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#import <QuartzCore/QuartzCore.h>
|
|
||||||
#import "MPPreferencesViewController.h"
|
#import "MPPreferencesViewController.h"
|
||||||
#import "MPiOSAppDelegate.h"
|
#import "MPiOSAppDelegate.h"
|
||||||
#import "MPAppDelegate_Key.h"
|
#import "MPAppDelegate_Key.h"
|
||||||
@ -99,7 +98,7 @@
|
|||||||
|
|
||||||
if (motion == UIEventSubtypeMotionShake) {
|
if (motion == UIEventSubtypeMotionShake) {
|
||||||
MPCheckpoint( MPCheckpointLogs, @{
|
MPCheckpoint( MPCheckpointLogs, @{
|
||||||
@"trace": [MPiOSConfig get].traceMode
|
@"trace" : [MPiOSConfig get].traceMode
|
||||||
} );
|
} );
|
||||||
[self performSegueWithIdentifier:@"MP_Logs" sender:self];
|
[self performSegueWithIdentifier:@"MP_Logs" sender:self];
|
||||||
}
|
}
|
||||||
|
@ -6,16 +6,13 @@
|
|||||||
// Copyright (c) 2012 Lyndir. All rights reserved.
|
// Copyright (c) 2012 Lyndir. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#import <QuartzCore/QuartzCore.h>
|
|
||||||
#import <Social/Social.h>
|
#import <Social/Social.h>
|
||||||
#import <CoreGraphics/CoreGraphics.h>
|
|
||||||
|
|
||||||
#import "MPUnlockViewController.h"
|
#import "MPUnlockViewController.h"
|
||||||
#import "MPiOSAppDelegate.h"
|
#import "MPiOSAppDelegate.h"
|
||||||
#import "MPAppDelegate_Key.h"
|
#import "MPAppDelegate_Key.h"
|
||||||
#import "MPAppDelegate_Store.h"
|
#import "MPAppDelegate_Store.h"
|
||||||
|
|
||||||
|
|
||||||
@interface MPUnlockViewController()
|
@interface MPUnlockViewController()
|
||||||
|
|
||||||
@property(strong, nonatomic) NSMutableDictionary *avatarToUserOID;
|
@property(strong, nonatomic) NSMutableDictionary *avatarToUserOID;
|
||||||
@ -30,7 +27,6 @@
|
|||||||
@property(nonatomic, strong) NSArray *marqueeTipTexts;
|
@property(nonatomic, strong) NSArray *marqueeTipTexts;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@implementation MPUnlockViewController {
|
@implementation MPUnlockViewController {
|
||||||
NSManagedObjectID *_selectedUserOID;
|
NSManagedObjectID *_selectedUserOID;
|
||||||
}
|
}
|
||||||
@ -932,7 +928,7 @@
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
MPCheckpoint( MPCheckpointCopyToPasteboard, @{
|
MPCheckpoint( MPCheckpointCopyToPasteboard, @{
|
||||||
@"type" : [MPAlgorithmDefault nameOfType:self.emergencyType],
|
@"type" : NilToNSNull([MPAlgorithmDefault nameOfType:self.emergencyType]),
|
||||||
@"version" : @MPAlgorithmDefaultVersion,
|
@"version" : @MPAlgorithmDefaultVersion,
|
||||||
@"emergency" : @YES,
|
@"emergency" : @YES,
|
||||||
} );
|
} );
|
||||||
|
@ -124,7 +124,7 @@
|
|||||||
if (message.level >= PearlLogLevelWarn)
|
if (message.level >= PearlLogLevelWarn)
|
||||||
MPCheckpoint( @"Problem", @{
|
MPCheckpoint( @"Problem", @{
|
||||||
@"level" : @(PearlLogLevelStr( message.level )),
|
@"level" : @(PearlLogLevelStr( message.level )),
|
||||||
@"message" : message.message
|
@"message" : NilToNSNull(message.message)
|
||||||
} );
|
} );
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
@ -207,25 +207,25 @@
|
|||||||
[[Crashlytics sharedInstance] setObjectValue:[PearlConfig get].reviewedVersion forKey:@"reviewedVersion"];
|
[[Crashlytics sharedInstance] setObjectValue:[PearlConfig get].reviewedVersion forKey:@"reviewedVersion"];
|
||||||
|
|
||||||
#ifdef TESTFLIGHT_SDK_VERSION
|
#ifdef TESTFLIGHT_SDK_VERSION
|
||||||
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([MPConfig get].rememberLogin)
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB( [MPConfig get].rememberLogin )
|
||||||
forKey:@"rememberLogin"];
|
forKey:@"rememberLogin"];
|
||||||
[TestFlight addCustomEnvironmentInformation:PearlStringB([self storeManager].cloudEnabled)
|
[TestFlight addCustomEnvironmentInformation:PearlStringB( [self storeManager].cloudEnabled )
|
||||||
forKey:@"iCloud"];
|
forKey:@"iCloud"];
|
||||||
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([MPConfig get].iCloudDecided)
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB( [MPConfig get].iCloudDecided )
|
||||||
forKey:@"iCloudDecided"];
|
forKey:@"iCloudDecided"];
|
||||||
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([MPiOSConfig get].sendInfo)
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB( [MPiOSConfig get].sendInfo )
|
||||||
forKey:@"sendInfo"];
|
forKey:@"sendInfo"];
|
||||||
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([MPiOSConfig get].helpHidden)
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB( [MPiOSConfig get].helpHidden )
|
||||||
forKey:@"helpHidden"];
|
forKey:@"helpHidden"];
|
||||||
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([MPiOSConfig get].showSetup)
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB( [MPiOSConfig get].showSetup )
|
||||||
forKey:@"showQuickStart"];
|
forKey:@"showQuickStart"];
|
||||||
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([PearlConfig get].firstRun)
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB( [PearlConfig get].firstRun )
|
||||||
forKey:@"firstRun"];
|
forKey:@"firstRun"];
|
||||||
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([PearlConfig get].launchCount)
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB( [PearlConfig get].launchCount )
|
||||||
forKey:@"launchCount"];
|
forKey:@"launchCount"];
|
||||||
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([PearlConfig get].askForReviews)
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB( [PearlConfig get].askForReviews )
|
||||||
forKey:@"askForReviews"];
|
forKey:@"askForReviews"];
|
||||||
[TestFlight addCustomEnvironmentInformation:PearlStringNSB([PearlConfig get].reviewAfterLaunches)
|
[TestFlight addCustomEnvironmentInformation:PearlStringNSB( [PearlConfig get].reviewAfterLaunches )
|
||||||
forKey:@"reviewAfterLaunches"];
|
forKey:@"reviewAfterLaunches"];
|
||||||
[TestFlight addCustomEnvironmentInformation:[PearlConfig get].reviewedVersion
|
[TestFlight addCustomEnvironmentInformation:[PearlConfig get].reviewedVersion
|
||||||
forKey:@"reviewedVersion"];
|
forKey:@"reviewedVersion"];
|
||||||
@ -271,17 +271,17 @@
|
|||||||
[[MPiOSAppDelegate get] showSetup];
|
[[MPiOSAppDelegate get] showSetup];
|
||||||
} );
|
} );
|
||||||
|
|
||||||
MPCheckpoint(MPCheckpointStarted, @{
|
MPCheckpoint( MPCheckpointStarted, @{
|
||||||
@"simulator" : PearlStringB([PearlDeviceUtils isSimulator]),
|
@"simulator" : PearlStringB( [PearlDeviceUtils isSimulator] ),
|
||||||
@"encrypted" : PearlStringB([PearlDeviceUtils isAppEncrypted]),
|
@"encrypted" : PearlStringB( [PearlDeviceUtils isAppEncrypted] ),
|
||||||
@"jailbroken" : PearlStringB([PearlDeviceUtils isJailbroken]),
|
@"jailbroken" : PearlStringB( [PearlDeviceUtils isJailbroken] ),
|
||||||
@"platform" : [PearlDeviceUtils platform],
|
@"platform" : [PearlDeviceUtils platform],
|
||||||
#ifdef APPSTORE
|
#ifdef APPSTORE
|
||||||
@"legal" : PearlStringB([PearlDeviceUtils isAppEncrypted]),
|
@"legal" : PearlStringB([PearlDeviceUtils isAppEncrypted]),
|
||||||
#else
|
#else
|
||||||
@"legal" : @"YES",
|
@"legal" : @"YES",
|
||||||
#endif
|
#endif
|
||||||
});
|
} );
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
@ -737,7 +737,7 @@
|
|||||||
NSString *testFlightToken = NSNullToNil([[self testFlightInfo] valueForKeyPath:@"Application Token"]);
|
NSString *testFlightToken = NSNullToNil([[self testFlightInfo] valueForKeyPath:@"Application Token"]);
|
||||||
if (![testFlightToken length])
|
if (![testFlightToken length])
|
||||||
wrn(@"TestFlight token not set. Test Flight won't be aware of this test.");
|
wrn(@"TestFlight token not set. Test Flight won't be aware of this test.");
|
||||||
|
|
||||||
return testFlightToken;
|
return testFlightToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -785,7 +785,7 @@
|
|||||||
#endif
|
#endif
|
||||||
if (![localyticsKey length])
|
if (![localyticsKey length])
|
||||||
wrn(@"Localytics key not set. Demographics won't be collected.");
|
wrn(@"Localytics key not set. Demographics won't be collected.");
|
||||||
|
|
||||||
return localyticsKey;
|
return localyticsKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user