Avoid crash during test runs

In tests that have writes occuring async WRT the test loop, we sometimes crash
when the transaction ends and we end the background task, because
CurrentAppContext() is momentarily nil between test runs.
pull/1/head
Michael Kirk 7 years ago
parent cc9dad02af
commit 456b2c0830

@ -86,7 +86,7 @@ NSString *const kNSUserDefaults_DatabaseExtensionVersionMap = @"kNSUserDefaults_
OWSAssertDebug(delegate.areAllRegistrationsComplete);
OWSBackgroundTask *_Nullable backgroundTask = nil;
if (CurrentAppContext().isMainApp) {
if (CurrentAppContext().isMainApp && !CurrentAppContext().isRunningTests) {
backgroundTask = [OWSBackgroundTask backgroundTaskWithLabelStr:__PRETTY_FUNCTION__];
}
[super readWriteWithBlock:block];

Loading…
Cancel
Save