From 6ce0ef62e964006da37c7fc60df776ce599b6121 Mon Sep 17 00:00:00 2001 From: Russell Hancox Date: Thu, 15 Oct 2015 18:31:07 -0400 Subject: [PATCH] SantaGUI: Ensure connection is only made on main thread --- Source/SantaGUI/SNTAppDelegate.m | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Source/SantaGUI/SNTAppDelegate.m b/Source/SantaGUI/SNTAppDelegate.m index bc16909c..defecf4f 100644 --- a/Source/SantaGUI/SNTAppDelegate.m +++ b/Source/SantaGUI/SNTAppDelegate.m @@ -71,17 +71,19 @@ #pragma mark Connection handling - (void)createConnection { - __weak __typeof(self) weakSelf = self; + dispatch_sync(dispatch_get_main_queue(), ^{ + __weak __typeof(self) weakSelf = self; - self.listener = [[SNTXPCConnection alloc] initClientWithName:[SNTXPCNotifierInterface serviceId] - options:NSXPCConnectionPrivileged]; - self.listener.exportedInterface = [SNTXPCNotifierInterface notifierInterface]; - self.listener.exportedObject = self.notificationManager; - self.listener.rejectedHandler = ^{ - [weakSelf attemptReconnection]; - }; - self.listener.invalidationHandler = self.listener.rejectedHandler; - [self.listener resume]; + self.listener = [[SNTXPCConnection alloc] initClientWithName:[SNTXPCNotifierInterface serviceId] + options:NSXPCConnectionPrivileged]; + self.listener.exportedInterface = [SNTXPCNotifierInterface notifierInterface]; + self.listener.exportedObject = self.notificationManager; + self.listener.rejectedHandler = ^{ + [weakSelf attemptReconnection]; + }; + self.listener.invalidationHandler = self.listener.rejectedHandler; + [self.listener resume]; + }); } - (void)attemptReconnection {