From c768f07087c769f12f7645e78dd42802da46048b Mon Sep 17 00:00:00 2001 From: Simone Manganelli Date: Thu, 2 Jul 2009 15:24:23 -0700 Subject: [PATCH] if the user chooses not to restart the host app after installing the new version of ClickToFlash, the Sparkle update status window now goes away and stops hanging around on screen, annoying the user (fixes bug #191) --- Plugin/Sparkle/SUUIBasedUpdateDriver.m | 12 +++++++++++- Plugin/SparkleManager.m | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Plugin/Sparkle/SUUIBasedUpdateDriver.m b/Plugin/Sparkle/SUUIBasedUpdateDriver.m index 2e83c9e4..2dfef64e 100644 --- a/Plugin/Sparkle/SUUIBasedUpdateDriver.m +++ b/Plugin/Sparkle/SUUIBasedUpdateDriver.m @@ -141,7 +141,17 @@ - (void)installUpdate { [statusController beginActionWithTitle:SULocalizedString(@"Installing update...", @"Take care not to overflow the status window.") maxProgressValue:0 statusText:nil]; [statusController setButtonEnabled:NO]; - [super installUpdate]; + [super installUpdate]; + + // modification by @simX, 2009-07-02; if a user chooses to not relaunch + // the app, the status window still stays on the screen; with this fix, + // it doesn't; unsure if this is the best place to do this, but it seems + // to work + if (statusController) + { + [statusController close]; + [statusController autorelease]; + } } - (void)abortUpdateWithError:(NSError *)error diff --git a/Plugin/SparkleManager.m b/Plugin/SparkleManager.m index 886aa511..e7ecad8d 100644 --- a/Plugin/SparkleManager.m +++ b/Plugin/SparkleManager.m @@ -124,6 +124,30 @@ - (NSString*)pathToRelaunchForUpdater:(SUUpdater*)updater { return _pathToRelaunch; } +- (BOOL)updater:(SUUpdater *)updater +shouldPostponeRelaunchForUpdate:(SUAppcastItem *)update + untilInvoking:(NSInvocation *)invocation; +{ + NSString *appNameString = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]; + int relaunchResult = NSRunAlertPanel([NSString stringWithFormat:@"Relaunch %@ now?",appNameString], + [NSString stringWithFormat:@"To use the new features of ClickToFlash, %@ needs to be relaunched.",appNameString], + @"Relaunch", + @"Do not relaunch", + nil); + + BOOL shouldPostpone = YES; + if (relaunchResult == NSAlertDefaultReturn) { + // we want to relaunch now, so don't postpone the relaunch + + shouldPostpone = NO; + } else { + // we want to postpone the relaunch and let the user decide when to do so, + // so we don't even bother with saving the invocation and reinvoking + // it later + } + return shouldPostpone; +} + - (NSString *)pathToRelaunch { return _pathToRelaunch;