From 8c6afef9544c264dcc9bcfd07aa2a71c4175248a Mon Sep 17 00:00:00 2001 From: "adam.fedor" Date: Tue, 13 Jun 2017 05:25:33 -0700 Subject: [PATCH] Make sure UI methods get called on the main thread BUG=webrtc:7754 Review-Url: https://codereview.webrtc.org/2920933002 Cr-Commit-Position: refs/heads/master@{#18563} --- .../AppRTCMobile/mac/APPRTCViewController.m | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/webrtc/examples/objc/AppRTCMobile/mac/APPRTCViewController.m b/webrtc/examples/objc/AppRTCMobile/mac/APPRTCViewController.m index d8ee1413f3..ab65b7e6d9 100644 --- a/webrtc/examples/objc/AppRTCMobile/mac/APPRTCViewController.m +++ b/webrtc/examples/objc/AppRTCMobile/mac/APPRTCViewController.m @@ -63,10 +63,12 @@ static NSUInteger const kBottomViewHeight = 200; - (void)displayLogMessage:(NSString *)message { - _logView.string = - [NSString stringWithFormat:@"%@%@\n", _logView.string, message]; - NSRange range = NSMakeRange(_logView.string.length, 0); - [_logView scrollRangeToVisible:range]; + dispatch_async(dispatch_get_main_queue(), ^{ + _logView.string = + [NSString stringWithFormat:@"%@%@\n", _logView.string, message]; + NSRange range = NSMakeRange(_logView.string.length, 0); + [_logView scrollRangeToVisible:range]; + }); } #pragma mark - Private @@ -414,9 +416,11 @@ static NSUInteger const kBottomViewHeight = 200; } - (void)showAlertWithMessage:(NSString*)message { - NSAlert* alert = [[NSAlert alloc] init]; - [alert setMessageText:message]; - [alert runModal]; + dispatch_async(dispatch_get_main_queue(), ^{ + NSAlert* alert = [[NSAlert alloc] init]; + [alert setMessageText:message]; + [alert runModal]; + }); } - (void)resetUI {