summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSho Amano <samano@xevo.com>2018-08-30 22:58:59 +0900
committerSho Amano <samano@xevo.com>2018-08-31 21:10:36 +0900
commitc7a053837c76f3e450a2b5d3c02537e7d4225ade (patch)
tree354e66f78ae6095101d6fa5752f2ec5d891d8f20
parent2beb476e7b43590a06d7470ce03e9e62b0fe3b80 (diff)
downloadsdl_ios-c7a053837c76f3e450a2b5d3c02537e7d4225ade.tar.gz
fix: lifecycle state machine not updated on dedicated queue when restarting
When restarting the manager, its `transitionToState:` is called on the main queue. To keep consistency, the state machine is fixed to run on its lifecycleQueue.
-rw-r--r--SmartDeviceLink/SDLLifecycleManager.m11
1 files changed, 9 insertions, 2 deletions
diff --git a/SmartDeviceLink/SDLLifecycleManager.m b/SmartDeviceLink/SDLLifecycleManager.m
index 2599d97ef..4f078b533 100644
--- a/SmartDeviceLink/SDLLifecycleManager.m
+++ b/SmartDeviceLink/SDLLifecycleManager.m
@@ -245,10 +245,17 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready";
// Apple Bug ID #30059457
__weak typeof(self) weakSelf = self;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [weakSelf.delegate managerDidDisconnect];
+ __strong typeof(weakSelf) strongSelf = weakSelf;
+ if (!strongSelf) {
+ return;
+ }
+
+ [strongSelf.delegate managerDidDisconnect];
if (shouldRestart) {
- [weakSelf.lifecycleStateMachine transitionToState:SDLLifecycleStateStarted];
+ dispatch_async(strongSelf.lifecycleQueue, ^{
+ [strongSelf.lifecycleStateMachine transitionToState:SDLLifecycleStateStarted];
+ });
}
});
}