mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Make sure PLCrashReporter only gets initialized once, even on manually invoking the method multiple times
And also catch the exception PLCrashReporter throws, if the develop is somehow trying to initialize it multiple times.
This commit is contained in:
parent
40041ad882
commit
ece5f8bc49
@ -93,6 +93,7 @@ static NSString *kBITCrashManagerStatus = @"BITCrashManagerStatus";
|
||||
NSURLConnection *_urlConnection;
|
||||
|
||||
BOOL _sendingInProgress;
|
||||
BOOL _isSetup;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user