Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only try to remove from run loop when we aren't closing #1495

Merged
merged 1 commit into from
Jan 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions SmartDeviceLink/SDLIAPSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ - (void)stopStream:(NSStream *)stream {
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;
Expand Down