From 8cdf61cf0788c60913c0a7321700e95ca826c945 Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Fri, 24 Nov 2017 06:01:22 +0100 Subject: [PATCH] Log on main thread --- Sources/VLLogWindow.mm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Sources/VLLogWindow.mm b/Sources/VLLogWindow.mm index 05e78ce..dc653d4 100644 --- a/Sources/VLLogWindow.mm +++ b/Sources/VLLogWindow.mm @@ -45,10 +45,11 @@ [log setString: logText]; while ((data = [h availableData]) && [data length]) { NSString * append = [[[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding] autorelease]; - [logText appendString: append]; - [log setString: logText]; - [log scrollRangeToVisible: NSMakeRange([logText length], 0)]; - + dispatch_sync(dispatch_get_main_queue(), ^{ + [logText appendString: append]; + [log setString: logText]; + [log scrollRangeToVisible: NSMakeRange([logText length], 0)]; + }); [pool release]; pool = [[NSAutoreleasePool alloc] init]; }