mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-27 05:04:27 +00:00
Add silent termination method to user driver
This is triggered if the update is automatically downloaded and the installer is started in the background, and the updater's delegate decides to handle silent installation and installs the update invoking its immediate installation block. In this scenario, this fixes an issue where the application may not be terminated silently.
This commit is contained in:
1 parent
c9a11a262d
commit
a6a2da7a69
5 files changed
+56
-19
No files matched your search
Vendored
+28
-16
@@ -403,25 +403,30 @@
|
||||
|
||||
#pragma mark Aborting Everything
|
||||
|
||||
- (BOOL)_terminateApplicationAndWillTerminateCurrentApplication
|
||||
{
|
||||
// Give the delegate a deferred chance for providing an application path
|
||||
// This is a private API and used by SUUpdater
|
||||
NSString *applicationPath = nil;
|
||||
if ([self.delegate respondsToSelector:@selector(_pathToTerminateForStandardUserDriver)]) {
|
||||
applicationPath = [(NSObject *)self.delegate _pathToTerminateForStandardUserDriver];
|
||||
}
|
||||
|
||||
NSBundle *applicationBundle;
|
||||
if (applicationPath != nil) {
|
||||
applicationBundle = [NSBundle bundleWithPath:applicationPath];
|
||||
assert(applicationBundle != nil);
|
||||
} else {
|
||||
applicationBundle = self.applicationBundle;
|
||||
}
|
||||
|
||||
return [self.uiComponent terminateApplicationForBundleAndWillTerminateCurrentApplication:applicationBundle];
|
||||
}
|
||||
|
||||
- (void)terminateApplication
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// Give the delegate a deferred chance for providing an application path
|
||||
// This is a private API and used by SUUpdater
|
||||
NSString *applicationPath = nil;
|
||||
if ([self.delegate respondsToSelector:@selector(_pathToTerminateForStandardUserDriver)]) {
|
||||
applicationPath = [(NSObject *)self.delegate _pathToTerminateForStandardUserDriver];
|
||||
}
|
||||
|
||||
NSBundle *applicationBundle;
|
||||
if (applicationPath != nil) {
|
||||
applicationBundle = [NSBundle bundleWithPath:applicationPath];
|
||||
assert(applicationBundle != nil);
|
||||
} else {
|
||||
applicationBundle = self.applicationBundle;
|
||||
}
|
||||
|
||||
if ([self.uiComponent terminateApplicationForBundleAndWillTerminateCurrentApplication:applicationBundle]) {
|
||||
if ([self _terminateApplicationAndWillTerminateCurrentApplication]) {
|
||||
// if a user chooses to NOT relaunch the app (as is the case with WebKit
|
||||
// when it asks you if you are sure you want to close the app with multiple
|
||||
// tabs open), the status window still stays on the screen and obscures
|
||||
@@ -434,6 +439,13 @@
|
||||
});
|
||||
}
|
||||
|
||||
- (void)terminateApplicationSilently
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self _terminateApplicationAndWillTerminateCurrentApplication];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)_dismissUpdateInstallation
|
||||
{
|
||||
// Make sure everything we call here does not dispatch async to main queue
|
||||
|
||||
Vendored
+15
-2
@@ -256,13 +256,26 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
|
||||
*
|
||||
* Sparkle is asking us to send a request to terminate the application.
|
||||
*
|
||||
* If this will terminate the current application, one may decide to dismiss progress UI in case the termination request is delayed or canceled.
|
||||
* Or if this will terminate a remote application, one may decide to show the user that the update is currently installing.
|
||||
* If this will terminate the current application, an implementor may decide to dismiss progress UI in case the termination request is delayed or canceled.
|
||||
* Or if this will terminate a remote application, an implementor may decide to show the user that the update is currently installing.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)terminateApplication;
|
||||
|
||||
/*!
|
||||
* Terminate the application silently.
|
||||
*
|
||||
* Sparkle is asking us to send a request to terminate the application without showing any UI interaction.
|
||||
* This may be invoked after Sparkle has downloaded an update in the background automatically,
|
||||
* and the updater's delegate has decided to install & relaunch the application without disrupting the user (think of a backgrounded application).
|
||||
*
|
||||
* After the application is terminated, the update will be installed and the application will be relaunched.
|
||||
*
|
||||
* This can be called from any thread
|
||||
*/
|
||||
- (void)terminateApplicationSilently;
|
||||
|
||||
/*!
|
||||
* Show the user that the update installation finished
|
||||
*
|
||||
|
||||
Vendored
+1
-1
@@ -105,7 +105,7 @@
|
||||
// otherwise the update driver will abort the update before then
|
||||
- (void)installerIsRequestingAppTermination
|
||||
{
|
||||
[self.userDriver terminateApplication];
|
||||
[self.userDriver terminateApplicationSilently];
|
||||
}
|
||||
|
||||
- (void)basicDriverIsRequestingAbortUpdateWithError:(NSError *)error
|
||||
|
||||
@@ -339,6 +339,13 @@
|
||||
});
|
||||
}
|
||||
|
||||
- (void)terminateApplicationSilently
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.uiComponent terminateApplicationForBundle:self.applicationBundle];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)_dismissUpdateInstallation
|
||||
{
|
||||
// Make sure everything we call here does not dispatch async to main queue
|
||||
|
||||
@@ -316,4 +316,9 @@
|
||||
});
|
||||
}
|
||||
|
||||
- (void)terminateApplicationSilently
|
||||
{
|
||||
[self terminateApplication];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user