X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/3e983c32a1d041b4493460187d76c0bb76007b82..3ee1edf966c9731ba8aef5173b5c5f6a69ff5045:/MenuTunes.m diff --git a/MenuTunes.m b/MenuTunes.m index bcc5590..81055ed 100755 --- a/MenuTunes.m +++ b/MenuTunes.m @@ -13,11 +13,9 @@ Things to do: - hot keys can't be set when NSBGOnly is on. The window is not key, so the KeyBroadcaster does not pick up key combos - going to need a different way of defining key combos -¥ Optimize, this thing is big and slow :( +¥ Optimize ¥ Apple Events! Apple Events! Apple Events! - -¥ I think I found a slight memory leak: - 425 MenuTunes 7.8% 8:29.87 1 56 4827 215M+ 3.14M 135M- 599M+ +¥ Upcoming songs menu items are disabled after launching iTunes and playing */ #import "MenuTunes.h" @@ -30,6 +28,7 @@ Things to do: - (void)applicationDidFinishLaunching:(NSNotification *)note { + asComponent = OpenDefaultComponent(kOSAComponentType, kAppleScriptSubtype); if (![[NSUserDefaults standardUserDefaults] objectForKey:@"menu"]) { [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"Play/Pause", @"Next Track", @"Previous Track", @"Fast Forward", @"Rewind", @"", @"Upcoming Songs", @"Playlists", @"", @"PreferencesÉ", @"Quit", @"", @"Current Track Info", nil] forKey:@"menu"]; @@ -75,6 +74,7 @@ target:self selector:@selector(timerUpdate) userInfo:nil repeats:YES]; { [refreshTimer invalidate]; } + CloseComponent(asComponent); [statusItem release]; [menu release]; [view release]; @@ -264,7 +264,6 @@ target:self selector:@selector(timerUpdate) userInfo:nil repeats:YES]; NSMenuItem *songItem; songItem = [[NSMenuItem alloc] initWithTitle:curSong action:@selector(playTrack:) keyEquivalent:@""]; [songItem setTarget:self]; - [songItem setEnabled:YES]; [songItem setRepresentedObject:[NSNumber numberWithInt:i]]; [upcomingSongsMenu addItem:songItem]; [songItem release]; @@ -398,7 +397,7 @@ target:self selector:@selector(timerUpdate) userInfo:nil repeats:YES]; AECreateDesc(typeChar, [script cString], [script cStringLength], &scriptDesc); - OSADoScript(OpenDefaultComponent(kOSAComponentType, kAppleScriptSubtype), &scriptDesc, kOSANullScript, typeChar, kOSAModeCanInteract, &resultDesc); + OSADoScript(asComponent, &scriptDesc, kOSANullScript, typeChar, kOSAModeCanInteract, &resultDesc); length = AEGetDescDataSize(&resultDesc); buffer = malloc(length);