From bb645e9832e71c6c3a6de129e3aba9eeb53faab1 Mon Sep 17 00:00:00 2001 From: Sergey Tatarchuk Date: Sat, 26 Oct 2013 00:50:14 +0300 Subject: [PATCH] Safer work with NSConnection --- SUUpdater.m | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/SUUpdater.m b/SUUpdater.m index 5d441d7f..ca329b85 100644 --- a/SUUpdater.m +++ b/SUUpdater.m @@ -48,11 +48,17 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault - (BOOL)isUpdateInProgress { BOOL result = NO; - NSConnection *connection = [NSConnection connectionWithRegisteredName:[NSString stringWithFormat:@"Sparkle %@", [[host bundle] bundleIdentifier]] host:nil]; - if (connection != nil) + @try + { + NSConnection *connection = [NSConnection connectionWithRegisteredName:[NSString stringWithFormat:@"Sparkle %@", [[host bundle] bundleIdentifier]] host:nil]; + if (connection != nil) + { + NSDistantObject *proxyBundle = [connection rootProxy]; + result = proxyBundle != nil; + } + } + @catch (NSException *exception) { - NSDistantObject *proxyBundle = [connection rootProxy]; - result = proxyBundle != nil; } return result;