diff --git a/Sparkle/SUAutomaticUpdateDriver.m b/Sparkle/SUAutomaticUpdateDriver.m index 175e01c3..d01e8b4a 100644 --- a/Sparkle/SUAutomaticUpdateDriver.m +++ b/Sparkle/SUAutomaticUpdateDriver.m @@ -47,7 +47,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 willUpdateOnTermination = YES; - if ([[updater delegate] respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationInvocation:)]) + id updaterDelegate = [updater delegate]; + if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdateOnQuit:immediateInstallationInvocation:)]) { BOOL relaunch = YES; BOOL showUI = NO; @@ -57,7 +58,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 [invocation setArgument:&showUI atIndex:3]; [invocation setTarget:self]; - [[updater delegate] updater:updater willInstallUpdateOnQuit:updateItem immediateInstallationInvocation:invocation]; + [updaterDelegate updater:updater willInstallUpdateOnQuit:updateItem immediateInstallationInvocation:invocation]; } // If this is marked as a critical update, we'll prompt the user to install it right away. @@ -84,8 +85,9 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 willUpdateOnTermination = NO; - if ([[updater delegate] respondsToSelector:@selector(updater:didCancelInstallUpdateOnQuit:)]) - [[updater delegate] updater:updater didCancelInstallUpdateOnQuit:updateItem]; + id updaterDelegate = [updater delegate]; + if ([updaterDelegate respondsToSelector:@selector(updater:didCancelInstallUpdateOnQuit:)]) + [updaterDelegate updater:updater didCancelInstallUpdateOnQuit:updateItem]; } } diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index c33d6edb..4d8d8399 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -299,21 +299,22 @@ // Give the host app an opportunity to postpone the install and relaunch. static BOOL postponedOnce = NO; - if (!postponedOnce && [[updater delegate] respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)]) + id updaterDelegate = [updater delegate]; + if (!postponedOnce && [updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)]) { NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]]; [invocation setSelector:@selector(installWithToolAndRelaunch:)]; [invocation setArgument:&relaunch atIndex:2]; [invocation setTarget:self]; postponedOnce = YES; - if ([[updater delegate] updater:updater shouldPostponeRelaunchForUpdate:updateItem untilInvoking:invocation]) { + if ([updaterDelegate updater:updater shouldPostponeRelaunchForUpdate:updateItem untilInvoking:invocation]) { return; } } - if ([[updater delegate] respondsToSelector:@selector(updater:willInstallUpdate:)]) { - [[updater delegate] updater:updater willInstallUpdate:updateItem]; + if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdate:)]) { + [updaterDelegate updater:updater willInstallUpdate:updateItem]; } NSString *const finishInstallToolName = FINISH_INSTALL_TOOL_NAME_STRING; @@ -335,8 +336,8 @@ } [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self]; - if ([[updater delegate] respondsToSelector:@selector(updaterWillRelaunchApplication:)]) - [[updater delegate] updaterWillRelaunchApplication:updater]; + if ([updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)]) + [updaterDelegate updaterWillRelaunchApplication:updater]; if(!relaunchPath || ![[NSFileManager defaultManager] fileExistsAtPath:relaunchPath]) { @@ -347,8 +348,8 @@ } NSString *pathToRelaunch = [host bundlePath]; - if ([[updater delegate] respondsToSelector:@selector(pathToRelaunchForUpdater:)]) { - pathToRelaunch = [[updater delegate] pathToRelaunchForUpdater:updater]; + if ([updaterDelegate respondsToSelector:@selector(pathToRelaunchForUpdater:)]) { + pathToRelaunch = [updaterDelegate pathToRelaunchForUpdater:updater]; } NSString *relaunchToolPath = [[relaunchPath stringByAppendingPathComponent: @"/Contents/MacOS"] stringByAppendingPathComponent: finishInstallToolName]; [NSTask launchedTaskWithLaunchPath: relaunchToolPath arguments:@[[host bundlePath], diff --git a/Sparkle/SUProbingUpdateDriver.m b/Sparkle/SUProbingUpdateDriver.m index a39166de..dc45b537 100644 --- a/Sparkle/SUProbingUpdateDriver.m +++ b/Sparkle/SUProbingUpdateDriver.m @@ -15,8 +15,10 @@ - (void)didFindValidUpdate { - if ([[updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) - [[updater delegate] updater:updater didFindValidUpdate:updateItem]; + id updaterDelegate = [updater delegate]; + + if ([updaterDelegate respondsToSelector:@selector(updater:didFindValidUpdate:)]) + [updaterDelegate updater:updater didFindValidUpdate:updateItem]; NSDictionary *userInfo = (updateItem != nil) ? @{SUUpdaterAppcastItemNotificationKey : updateItem} : nil; [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification object:updater userInfo:userInfo]; [self abortUpdate]; @@ -24,8 +26,10 @@ - (void)didNotFindUpdate { - if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) { - [[updater delegate] updaterDidNotFindUpdate:updater]; + id updaterDelegate = [updater delegate]; + + if ([updaterDelegate respondsToSelector:@selector(updaterDidNotFindUpdate:)]) { + [updaterDelegate updaterDidNotFindUpdate:updater]; } [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater]; diff --git a/Sparkle/SUScheduledUpdateDriver.m b/Sparkle/SUScheduledUpdateDriver.m index 46b1e70c..7a7b486d 100644 --- a/Sparkle/SUScheduledUpdateDriver.m +++ b/Sparkle/SUScheduledUpdateDriver.m @@ -23,8 +23,10 @@ - (void)didNotFindUpdate { - if ([[updater delegate] respondsToSelector:@selector(updaterDidNotFindUpdate:)]) { - [[updater delegate] updaterDidNotFindUpdate:updater]; + id updaterDelegate = [updater delegate]; + + if ([updaterDelegate respondsToSelector:@selector(updaterDidNotFindUpdate:)]) { + [updaterDelegate updaterDidNotFindUpdate:updater]; } [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:updater];