diff --git a/Classes/BITCrashManager.h b/Classes/BITCrashManager.h index 4edbfe6dd6..ca40c43e57 100644 --- a/Classes/BITCrashManager.h +++ b/Classes/BITCrashManager.h @@ -93,6 +93,7 @@ static NSString *kBITCrashManagerStatus = @"BITCrashManagerStatus"; NSURLConnection *_urlConnection; BOOL _sendingInProgress; + BOOL _isSetup; } diff --git a/Classes/BITCrashManager.m b/Classes/BITCrashManager.m index 75baa7f4b4..6ac77ebfc9 100644 --- a/Classes/BITCrashManager.m +++ b/Classes/BITCrashManager.m @@ -75,6 +75,7 @@ _delegate = nil; _showAlwaysButton = NO; + _isSetup = NO; _crashIdenticalCurrentVersion = YES; _urlConnection = nil; @@ -422,18 +423,29 @@ - (void)startManager { if (_crashManagerStatus == BITCrashManagerStatusDisabled) return; - PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter]; - NSError *error = NULL; - - // Check if we previously crashed - if ([crashReporter hasPendingCrashReport]) { - _didCrashInLastSession = YES; - [self handleCrashReport]; + if (!_isSetup) { + PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter]; + NSError *error = NULL; + + // Check if we previously crashed + if ([crashReporter hasPendingCrashReport]) { + _didCrashInLastSession = YES; + [self handleCrashReport]; + } + + // PLCrashReporter is throwing an NSException if it is being enabled again + // even though it already is enabled + @try { + // Enable the Crash Reporter + if (![crashReporter enableCrashReporterAndReturnError: &error]) + NSLog(@"WARNING: Could not enable crash reporter: %@", [error localizedDescription]); + } + @catch (NSException * e) { + NSLog(@"WARNING: %@", [e reason]); + } + + _isSetup = NO; } - - // Enable the Crash Reporter - if (![crashReporter enableCrashReporterAndReturnError: &error]) - NSLog(@"WARNING: Could not enable crash reporter: %@", [error localizedDescription]); [self performSelector:@selector(invokeDelayedProcessing) withObject:nil afterDelay:0.5]; }