From 3b76ecd40d1eb7974d7ef73df2c454c8eb28cf35 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Mon, 11 Feb 2019 11:08:51 +0100 Subject: [PATCH] Fix accessing the UI from non main thread --- VNCController.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/VNCController.m b/VNCController.m index dbff4a6..24fbdaa 100644 --- a/VNCController.m +++ b/VNCController.m @@ -292,10 +292,17 @@ - (void) dedicatedUpdateHostInfoThread { [ipString replaceCharactersInRange:NSMakeRange(ipString.length,0) withString:@"\tInternal"]; } - if (controller && !limitToLocalConnections.state) { // Colorize and add tooltip - + __block BOOL isLimitToLocalConnectionsEnabled; + __block int runningPortNum; + dispatch_sync(dispatch_get_main_queue(), ^{ + isLimitToLocalConnectionsEnabled = limitToLocalConnections.state; + runningPortNum = self.runningPortNum; + }); + + if (controller && !isLimitToLocalConnectionsEnabled) { // Colorize and add tooltip + NSURL *testURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@:%d", - anIP, self.runningPortNum]]; + anIP, runningPortNum]]; NSData *testData = [NSData dataWithContentsOfURL:testURL]; NSString *testString = (testData.length ? [NSString stringWithUTF8String: testData.bytes] : @"");