Skip to content

Commit

Permalink
prevent leak in storePreviouslyActiveApp
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin committed Sep 26, 2009
1 parent 1d8f877 commit eb4832e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Visor.m
Expand Up @@ -520,10 +520,12 @@ - (id) init {
LOG(@"Visor init");

runningApplicationClass = NSClassFromString(@"NSRunningApplication"); // 10.6

NSString* path = [[NSBundle bundleForClass:[self class]] pathForResource:@"RestoreApp" ofType:@"scpt"];
restoreAppAppleScriptSource = [[NSString alloc] initWithContentsOfFile:path encoding:NSMacOSRomanStringEncoding error:NULL];
scriptError = [[NSDictionary alloc] init];
if (!runningApplicationClass) {
// 10.5 path
NSString* path = [[NSBundle bundleForClass:[self class]] pathForResource:@"RestoreApp" ofType:@"scpt"];
restoreAppAppleScriptSource = [[NSString alloc] initWithContentsOfFile:path encoding:NSMacOSRomanStringEncoding error:NULL];
scriptError = [[NSDictionary alloc] init];
}

window = NULL;

Expand Down Expand Up @@ -848,7 +850,7 @@ - (void)storePreviouslyActiveApp {
NSDictionary *activeAppDict = [[NSWorkspace sharedWorkspace] activeApplication];
previouslyActiveAppPath = nil;
if ([[activeAppDict objectForKey:@"NSApplicationBundleIdentifier"] compare:@"com.apple.Terminal"]) {
previouslyActiveAppPath = [[NSString alloc] initWithString:[activeAppDict objectForKey:@"NSApplicationPath"]];
previouslyActiveAppPath = [activeAppDict objectForKey:@"NSApplicationPath"];
}
LOG(@" (10.5) -> %@", previouslyActiveAppPath);
} else {
Expand Down

0 comments on commit eb4832e

Please sign in to comment.