diff options
author | ritsuka <[email protected]> | 2013-09-28 06:34:34 +0000 |
---|---|---|
committer | ritsuka <[email protected]> | 2013-09-28 06:34:34 +0000 |
commit | 39d824512056405321ba2b192508037323f59409 (patch) | |
tree | c67b5278f724966ebd0472a41ed7d8816d24fbbc /macosx | |
parent | 954462c36441af7b3c6d02450cc7edf892cae99e (diff) |
MacGUI: Replace deprecated NSWorkspace API calls. Patch by Alexander Zautke.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5817 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/Controller.m | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/macosx/Controller.m b/macosx/Controller.m index 1dca55413..c1c53be90 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -421,35 +421,36 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It - (int) hbInstances { /* check to see if another instance of HandBrake.app is running */ - NSArray *runningAppDictionaries = [[NSWorkspace sharedWorkspace] launchedApplications]; - NSDictionary *runningAppsDictionary; + NSArray *runningInstances = [NSRunningApplication runningApplicationsWithBundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]]; + NSRunningApplication *runningInstance; + + NSRunningApplication *thisInstance = [NSRunningApplication currentApplication]; + NSString *thisInstanceAppPath = [[NSBundle mainBundle] bundlePath]; + [self writeToActivityLog: "hbInstances path to this instance: %s", [thisInstanceAppPath UTF8String]]; + int hbInstances = 0; - NSString * thisInstanceAppPath = [[NSBundle mainBundle] bundlePath]; - NSString * runningInstanceAppPath; + NSString *runningInstanceAppPath; int runningInstancePidNum; - [self writeToActivityLog: "hbInstances path to this instance: %s", [thisInstanceAppPath UTF8String]]; - for (runningAppsDictionary in runningAppDictionaries) + + for (runningInstance in runningInstances) { - if ([[runningAppsDictionary valueForKey:@"NSApplicationName"] isEqualToString:@"HandBrake"]) - { - /*Report the path to each active instances app path */ - runningInstancePidNum = [[runningAppsDictionary valueForKey:@"NSApplicationProcessIdentifier"] intValue]; - runningInstanceAppPath = [runningAppsDictionary valueForKey:@"NSApplicationPath"]; - [self writeToActivityLog: "hbInstance found instance pidnum:%d at path: %s", runningInstancePidNum, [runningInstanceAppPath UTF8String]]; - /* see if this is us by comparing the app path */ - if ([runningInstanceAppPath isEqualToString: thisInstanceAppPath]) - { - /* If so this is our pidnum */ - [self writeToActivityLog: "hbInstance MATCH FOUND, our pidnum is:%d", runningInstancePidNum]; - /* Get the PID number for this hb instance, used in multi instance encoding */ - pidNum = runningInstancePidNum; - /* Report this pid to the activity log */ - [self writeToActivityLog: "Pid for this instance:%d", pidNum]; - /* Tell fQueueController what our pidNum is */ - [fQueueController setPidNum:pidNum]; - } - hbInstances++; - } + /*Report the path to each active instances app path */ + runningInstancePidNum = [runningInstance processIdentifier]; + runningInstanceAppPath = [[runningInstance bundleURL] path]; + [self writeToActivityLog: "hbInstance found instance pidnum: %d at path: %s", runningInstancePidNum, [runningInstanceAppPath UTF8String]]; + /* see if this is us*/ + if ([runningInstance isEqual: thisInstance]) + { + /* If so this is our pidnum */ + [self writeToActivityLog: "hbInstance MATCH FOUND, our pidnum is: %d", runningInstancePidNum]; + /* Get the PID number for this hb instance, used in multi instance encoding */ + pidNum = runningInstancePidNum; + /* Report this pid to the activity log */ + [self writeToActivityLog: "Pid for this instance: %d", pidNum]; + /* Tell fQueueController what our pidNum is */ + [fQueueController setPidNum:pidNum]; + } + hbInstances++; } return hbInstances; } |