Merge pull request #148 from mattstevens/silent-update-fixes

Silent update fixes
This commit is contained in:
Andy Matuschak committed 2012-02-14 09:45:01 -08:00
commit 320b3aa62a
2 files changed
+21 -2

No files matched your search

+1
View File
@@ -17,6 +17,7 @@
{
@private
BOOL showErrors;
BOOL willUpdateOnTermination;
SUAutomaticUpdateAlert *alert;
NSTimer *showUpdateAlertTimer;
}
+20 -2
View File
@@ -38,6 +38,16 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
- (void)unarchiverDidFinish:(SUUnarchiver *)ua
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
// Sudden termination is available on 10.6+
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
if ([processInfo respondsToSelector:@selector(disableSuddenTermination)]) {
[processInfo disableSuddenTermination];
}
willUpdateOnTermination = YES;
// If this is marked as a critical update, we'll prompt the user to install it right away.
if ([updateItem isCriticalUpdate])
{
@@ -45,14 +55,21 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
}
else
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil];
showUpdateAlertTimer = [[NSTimer scheduledTimerWithTimeInterval:SUAutomaticUpdatePromptImpatienceTimer target:self selector:@selector(showUpdateAlert) userInfo:nil repeats:NO] retain];
}
}
- (void)stopUpdatingOnTermination
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationWillTerminateNotification object:nil];
if (willUpdateOnTermination)
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationWillTerminateNotification object:nil];
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
if ([processInfo respondsToSelector:@selector(enableSuddenTermination)]) {
[processInfo enableSuddenTermination];
}
willUpdateOnTermination = NO;
}
}
- (void)invalidateShowUpdateAlertTimer
@@ -64,6 +81,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2
- (void)dealloc
{
[self stopUpdatingOnTermination];
[self invalidateShowUpdateAlertTimer];
[alert release];
[super dealloc];