diff --git a/Sparkle/SPUApplicationInfo.h b/Sparkle/SPUApplicationInfo.h index ff39e8ef..ff994e1a 100644 --- a/Sparkle/SPUApplicationInfo.h +++ b/Sparkle/SPUApplicationInfo.h @@ -16,6 +16,8 @@ NS_ASSUME_NONNULL_BEGIN + (NSImage *)bestIconForBundle:(NSBundle *)bundle; ++ (NSArray *)runningApplicationsWithBundle:(NSBundle *)bundle; + + (NSRunningApplication * _Nullable)runningApplicationWithBundle:(NSBundle *)bundle; @end diff --git a/Sparkle/SPUApplicationInfo.m b/Sparkle/SPUApplicationInfo.m index 8ab91981..786ae437 100644 --- a/Sparkle/SPUApplicationInfo.m +++ b/Sparkle/SPUApplicationInfo.m @@ -33,12 +33,14 @@ return icon; } -+ (NSRunningApplication *)runningApplicationWithBundle:(NSBundle *)bundle ++ (NSArray *)runningApplicationsWithBundle:(NSBundle *)bundle { // Resolve symlinks otherwise when we compare file paths, we may not realize two paths that are represented differently are the same NSArray *bundlePathComponents = bundle.bundlePath.stringByResolvingSymlinksInPath.pathComponents; NSString *bundleIdentifier = bundle.bundleIdentifier; + NSMutableArray *matchedRunningApplications = [[NSMutableArray alloc] init]; + if (bundleIdentifier != nil && bundlePathComponents != nil) { NSArray *runningApplications = (bundleIdentifier != nil) ? @@ -49,11 +51,17 @@ // Comparing the URLs hasn't worked well for me in practice, so I'm comparing the file paths instead NSString *candidatePath = runningApplication.bundleURL.URLByResolvingSymlinksInPath.path; if (candidatePath != nil && [candidatePath.pathComponents isEqualToArray:bundlePathComponents]) { - return runningApplication; + [matchedRunningApplications addObject:runningApplication]; } } } - return nil; + + return [matchedRunningApplications copy]; +} + ++ (NSRunningApplication *)runningApplicationWithBundle:(NSBundle *)bundle +{ + return [[self runningApplicationsWithBundle:bundle] firstObject]; } @end diff --git a/Sparkle/SPUUserDriverUIComponent.m b/Sparkle/SPUUserDriverUIComponent.m index 2836c5f5..07a6140c 100644 --- a/Sparkle/SPUUserDriverUIComponent.m +++ b/Sparkle/SPUUserDriverUIComponent.m @@ -21,8 +21,8 @@ - (void)terminateApplicationForBundle:(NSBundle *)bundle { - NSRunningApplication *runningApplication = [SPUApplicationInfo runningApplicationWithBundle:bundle]; - if (runningApplication != nil) { + NSArray *runningApplications = [SPUApplicationInfo runningApplicationsWithBundle:bundle]; + for (NSRunningApplication *runningApplication in runningApplications) { [runningApplication terminate]; } }