diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2018-01-05 09:33:45 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-05 09:33:45 -0500 |
commit | b7c427d8ed32bc0cfc37c84fc8f852a577a598d3 (patch) | |
tree | f7a16d172ad3a372cdd7fb86b19fe395cf81356d | |
parent | 319f618a6837eb014c44bb563f18aae55ae3708b (diff) | |
parent | b7744bbf390a7b7e4ec41385c293ecc2a50dc371 (diff) | |
download | sdl_ios-b7c427d8ed32bc0cfc37c84fc8f852a577a598d3.tar.gz |
Merge pull request #832 from smartdevicelink/bugs/issue_831_iapsession_assert
Force `stop` to run on the main thread
-rw-r--r-- | SmartDeviceLink/SDLIAPSession.m | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/SmartDeviceLink/SDLIAPSession.m b/SmartDeviceLink/SDLIAPSession.m index db64bf678..33a7cf1f1 100644 --- a/SmartDeviceLink/SDLIAPSession.m +++ b/SmartDeviceLink/SDLIAPSession.m @@ -81,8 +81,16 @@ NSTimeInterval const StreamThreadWaitSecs = 1.0; - (void)stop { // This method must be called on the main thread - NSAssert([NSThread isMainThread], @"stop must be called on the main thread"); - + if ([NSThread isMainThread]) { + [self sdl_stop]; + } else { + dispatch_sync(dispatch_get_main_queue(), ^{ + [self sdl_stop]; + }); + } +} + +- (void)sdl_stop { if (self.isDataSession) { [self.ioStreamThread cancel]; |