From ac4e4e405bd35c603e8208953f1497aead751585 Mon Sep 17 00:00:00 2001 From: Andy Matuschak Date: Wed, 23 Jul 2008 20:27:01 -0700 Subject: [PATCH] Fixes 245991 COMPATIBILITY ISSUE: Changed updatePreferencesChanged to resetUpdateCycle to give better semantics for bundle-ish apps which need to start the update cycle manually since applicationDidFinishLaunching: won't do the right thing. --- SUUpdater.h | 5 ++--- SUUpdater.m | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/SUUpdater.h b/SUUpdater.h index cf9cb4dc..ad7df7ac 100644 --- a/SUUpdater.h +++ b/SUUpdater.h @@ -40,9 +40,8 @@ // This forces an update to begin with a particular driver (see SU*UpdateDriver.h) - (void)checkForUpdatesWithDriver:(SUUpdateDriver *)driver; -// Call this to appropriately reschedule or cancel the update checking timer if preferences for time interval or automatic checks change. -// If you're using a .app, this'll be picked up automatically via NSUserDefaultsController, but for non-.apps, there's no way to observe changes. -- (void)updatePreferencesChanged; +// Call this to appropriately schedule or cancel the update checking timer according to the preferences for time interval and automatic checks. +- (void)resetUpdateCycle; - (BOOL)updateInProgress; @end diff --git a/SUUpdater.m b/SUUpdater.m index 1984b5a6..f79b8432 100644 --- a/SUUpdater.m +++ b/SUUpdater.m @@ -117,7 +117,7 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv BOOL automaticallyCheck = (result == SUAutomaticallyCheck); [host setBool:automaticallyCheck forUserDefaultsKey:SUEnableAutomaticChecksKey]; // Schedule checks, but make sure we ignore the delayed call from KVO - [self updatePreferencesChanged]; + [self resetUpdateCycle]; } - (void)updateDriverDidFinish:(NSNotification *)note @@ -206,9 +206,9 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv { // Allow a small delay, because perhaps the user or developer wants to change both preferences. This allows the developer to interpret a zero check interval as a sign to disable automatic checking. // Or we may get this from the developer and from our own KVO observation, this will effectively coalesce them. - [[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(updatePreferencesChanged) object:nil]; - [self performSelector:@selector(updatePreferencesChanged) withObject:nil afterDelay:15]; - [self updatePreferencesChanged]; + [[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil]; + [self performSelector:@selector(resetUpdateCycle) withObject:nil afterDelay:15]; + [self resetUpdateCycle]; } else { @@ -216,9 +216,9 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv } } -- (void)updatePreferencesChanged +- (void)resetUpdateCycle { - [[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(updatePreferencesChanged) object:nil]; + [[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil]; [self scheduleNextUpdateCheck]; }