From f55a6e1ab30acc7d4690d1b9c1fe7b78abc11ac9 Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Fri, 26 Aug 2011 20:24:10 +0000 Subject: [PATCH] Look for running copy of Lilypond.app --- Sources/VLAppController.mm | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Sources/VLAppController.mm b/Sources/VLAppController.mm index c157cfc..d41b911 100644 --- a/Sources/VLAppController.mm +++ b/Sources/VLAppController.mm @@ -129,11 +129,23 @@ else appPath = lilyPath; } - if (!appPath) - appPath = - [[[NSWorkspace sharedWorkspace] - absolutePathForAppBundleWithIdentifier:@"org.lilypond.lilypond"] - stringByAppendingPathComponent:@"Contents/Resources/bin/lilypond"]; + if (!appPath) { + // + // Look for running copies of Lilypond first + // + NSArray * runningApps = [[NSWorkspace sharedWorkspace] launchedApplications]; + for (NSDictionary * app in runningApps) + if ([[app objectForKey:@"NSApplicationBundleIdentifier"] isEqual:@"org.lilypond.lilypond"] + || [[app objectForKey:@"NSApplicationName"] isEqual:@"LilyPond"] + ) + if ((appPath = [[app objectForKey:@"NSApplicationPath"] stringByAppendingPathComponent:@"Contents/Resources/bin/lilypond"])) + break; + if (!appPath) + appPath = + [[[NSWorkspace sharedWorkspace] + absolutePathForAppBundleWithIdentifier:@"org.lilypond.lilypond"] + stringByAppendingPathComponent:@"Contents/Resources/bin/lilypond"]; + } if (!toolPath) toolPath = [self getLineFromCommand:@"bash -l -c 'which lilypond'"];