From ea472ae3f0716b1dd38f0403e76933807f447e6c Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 20 Feb 2021 19:40:02 -0800 Subject: [PATCH] Add updater:shouldPostponeRelaunchForUpdate: 1.x stub --- Sparkle/SUUpdater.m | 3 +++ Sparkle/SUUpdaterDelegate.h | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index 97618849..eedfb4d2 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -405,6 +405,9 @@ static NSMutableDictionary *sharedUpdaters = nil; self.postponedInstallHandler = installHandler; shouldPostponeRelaunch = [self.delegate updater:self shouldPostponeRelaunchForUpdate:item untilInvoking:invocation]; + } else if ([self.delegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:)]) { + // This API should really take a block, but not fixing a 1.x mishap now + shouldPostponeRelaunch = [self.delegate updater:self shouldPostponeRelaunchForUpdate:item]; } return shouldPostponeRelaunch; diff --git a/Sparkle/SUUpdaterDelegate.h b/Sparkle/SUUpdaterDelegate.h index c625e14a..e601fb2a 100644 --- a/Sparkle/SUUpdaterDelegate.h +++ b/Sparkle/SUUpdaterDelegate.h @@ -208,6 +208,21 @@ __deprecated_msg("See SPUUpdaterDelegate instead") */ - (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvoking:(NSInvocation *)invocation; +/*! + Returns whether the relaunch should be delayed in order to perform other tasks. + + This is not called if the user didn't relaunch on the previous update, + in that case it will immediately restart. + + This method acts as a simpler alternative to SUUpdaterDelegate::updater:shouldPostponeRelaunchForUpdate:untilInvoking: avoiding usage of NSInvocation, which is not available in Swift environments. + + \param updater The SUUpdater instance. + \param item The appcast item corresponding to the update that is proposed to be installed. + + \return \c YES to delay the relaunch. + */ +- (BOOL)updater:(SUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item; + /*! Returns whether the application should be relaunched at all.