diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2020-03-13 14:47:56 -0400 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2020-03-13 14:47:56 -0400 |
commit | ea82228a24b8f5805ace28a49385ace3eb2162f9 (patch) | |
tree | 05814a01acdaa49f338e05735887a786da2ea745 | |
parent | 76f7c5d6d2800402d81f9149b75c6dba6eae7634 (diff) | |
download | sdl_ios-bugfix/issue-1504-lock-screen-dismiss-animation.tar.gz |
Fix lock screen bugbugfix/issue-1504-lock-screen-dismiss-animation
* Make sure `stop` completion handler is always called
* Use strong / weak in all blocks
-rw-r--r-- | SmartDeviceLink/SDLLockScreenPresenter.m | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/SmartDeviceLink/SDLLockScreenPresenter.m b/SmartDeviceLink/SDLLockScreenPresenter.m index 8e6c8b080..b891171b3 100644 --- a/SmartDeviceLink/SDLLockScreenPresenter.m +++ b/SmartDeviceLink/SDLLockScreenPresenter.m @@ -41,14 +41,20 @@ NS_ASSUME_NONNULL_BEGIN self.shouldShowLockScreen = NO; if (self.lockWindow == nil) { + if (completionHandler != nil) { + completionHandler(); + } return; } // Dismiss and destroy the lockscreen window + __weak typeof(self) weakSelf = self; [self sdl_dismissWithCompletionHandler:^(BOOL success) { + __strong typeof(weakSelf) strongSelf = weakSelf; + if (success) { - self.lockWindow = nil; - self.lockViewController = nil; + strongSelf.lockWindow = nil; + strongSelf.lockViewController = nil; } if (completionHandler != nil) { @@ -63,27 +69,30 @@ NS_ASSUME_NONNULL_BEGIN // Store the expected state of the lockscreen self.shouldShowLockScreen = show; + __weak typeof(self) weakSelf = self; if (show) { [self sdl_presentWithCompletionHandler:^{ - if (self.shouldShowLockScreen) { + __strong typeof(weakSelf) strongSelf = weakSelf; + if (strongSelf.shouldShowLockScreen) { if (completionHandler != nil) { completionHandler(); } return; } SDLLogV(@"The lockscreen has been presented but needs to be dismissed"); - [self sdl_dismissWithCompletionHandler:^(BOOL success) { + [strongSelf sdl_dismissWithCompletionHandler:^(BOOL success) { if (completionHandler != nil) { completionHandler(); } }]; }]; } else { [self sdl_dismissWithCompletionHandler:^(BOOL success) { - if (!self.shouldShowLockScreen) { + __strong typeof(weakSelf) strongSelf = weakSelf; + if (!strongSelf.shouldShowLockScreen) { if (completionHandler != nil) { completionHandler(); } return; } SDLLogV(@"The lockscreen has been dismissed but needs to be presented"); - [self sdl_presentWithCompletionHandler:completionHandler]; + [strongSelf sdl_presentWithCompletionHandler:completionHandler]; }]; } } |