Make sure multiple setup runs are ignored

If the `configure` initializers or `startManager` are invoked multiple times, this can cause undefined behaviour and crashes. Hence we simply ignore if they are invoked multiple times.
This commit is contained in:
Andreas Linde 2014-08-26 17:31:57 +02:00
parent 20a777ccf8
commit d7e17d2f1c

View File

@ -88,6 +88,8 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h
BOOL _startUpdateManagerIsInvoked; BOOL _startUpdateManagerIsInvoked;
BOOL _managersInitialized;
BITHockeyAppClient *_hockeyAppClient; BITHockeyAppClient *_hockeyAppClient;
} }
@ -134,6 +136,7 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h
if ((self = [super init])) { if ((self = [super init])) {
_serverURL = nil; _serverURL = nil;
_delegate = nil; _delegate = nil;
_managersInitialized = NO;
_hockeyAppClient = nil; _hockeyAppClient = nil;
@ -209,6 +212,7 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h
- (void)startManager { - (void)startManager {
if (!_validAppIdentifier) return; if (!_validAppIdentifier) return;
if (_startManagerIsInvoked) return;
if (![self isSetUpOnMainThread]) return; if (![self isSetUpOnMainThread]) return;
@ -584,6 +588,8 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h
} }
- (void)initializeModules { - (void)initializeModules {
if (_managersInitialized) return;
_validAppIdentifier = [self checkValidityOfAppIdentifier:_appIdentifier]; _validAppIdentifier = [self checkValidityOfAppIdentifier:_appIdentifier];
if (![self isSetUpOnMainThread]) return; if (![self isSetUpOnMainThread]) return;
@ -628,6 +634,7 @@ bitstadium_info_t bitstadium_library_info __attribute__((section("__TEXT,__bit_h
[self pingServerForIntegrationStartWorkflowWithTimeString:integrationFlowTime appIdentifier:_appIdentifier]; [self pingServerForIntegrationStartWorkflowWithTimeString:integrationFlowTime appIdentifier:_appIdentifier];
} }
} }
_managersInitialized = YES;
} else { } else {
[self logInvalidIdentifier:@"app identifier"]; [self logInvalidIdentifier:@"app identifier"];
} }