diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2019-12-09 14:41:48 -0500 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2019-12-09 14:41:48 -0500 |
commit | 1e56cc84c11a259aff817c054756995e95f1782f (patch) | |
tree | 6af7d3d8e673722be3aba6f6547a3449aabad400 | |
parent | 2bb4b07c5e81dfcb7d5fafd92edcabb7e15eb994 (diff) | |
download | sdl_ios-bugfix/issue-1494-background-crashes.tar.gz |
Only try to remove from run loop when we aren't closingbugfix/issue-1494-background-crashes
* It will be implicitly removed when the stream is closed
-rw-r--r-- | SmartDeviceLink/SDLIAPSession.m | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/SmartDeviceLink/SDLIAPSession.m b/SmartDeviceLink/SDLIAPSession.m index 96844b3a7..c69efce6d 100644 --- a/SmartDeviceLink/SDLIAPSession.m +++ b/SmartDeviceLink/SDLIAPSession.m @@ -61,10 +61,12 @@ NS_ASSUME_NONNULL_BEGIN if (status1 != NSStreamStatusNotOpen && status1 != NSStreamStatusClosed) { [stream close]; + } else if (status1 == NSStreamStatusNotOpen) { + // It's implicitly removed from the stream when it's closed, but not if it was never opened. + // When the USB cable is disconnected, the app will will call this method after the `NSStreamEventEndEncountered` event. The stream will already be in the closed state but it still needs to be removed from the run loop. + [stream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; } - // When the USB cable is disconnected, the app will will call this method after the `NSStreamEventEndEncountered` event. The stream will already be in the closed state but it still needs to be removed from the run loop. - [stream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; [stream setDelegate:nil]; NSUInteger status2 = stream.streamStatus; |