mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-25 04:47:55 +00:00
Merge pull request #148 from mattstevens/silent-update-fixes
Silent update fixes
This commit is contained in:
commit
320b3aa62a
2 files changed
+21
-2
No files matched your search
@@ -17,6 +17,7 @@
|
||||
{
|
||||
@private
|
||||
BOOL showErrors;
|
||||
BOOL willUpdateOnTermination;
|
||||
SUAutomaticUpdateAlert *alert;
|
||||
NSTimer *showUpdateAlertTimer;
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in new issue
Block a user