X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/fcbc4baf73d5054212eb69f728ef9c303e1c62a5..3e983c32a1d041b4493460187d76c0bb76007b82:/MenuTunes.m?ds=inline diff --git a/MenuTunes.m b/MenuTunes.m index 0227042..bcc5590 100755 --- a/MenuTunes.m +++ b/MenuTunes.m @@ -15,6 +15,9 @@ Things to do: - going to need a different way of defining key combos ¥ Optimize, this thing is big and slow :( ¥ 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+ */ #import "MenuTunes.h" @@ -155,6 +158,7 @@ target:self selector:@selector(timerUpdate) userInfo:nil repeats:YES]; [menu addItem:[NSMenuItem separatorItem]]; } } + curTrackIndex = -1; //Force update of everything [self timerUpdate]; //Updates dynamic info in the menu @@ -400,6 +404,8 @@ target:self selector:@selector(timerUpdate) userInfo:nil repeats:YES]; buffer = malloc(length); AEGetDescData(&resultDesc, buffer, length); + AEDisposeDesc(&scriptDesc); + AEDisposeDesc(&resultDesc); result = [NSString stringWithCString:buffer length:length]; if (![result isEqualToString:@""] && ([result characterAtIndex:0] == '\"') && @@ -416,15 +422,17 @@ target:self selector:@selector(timerUpdate) userInfo:nil repeats:YES]; - (void)timerUpdate { int pid; + if (GetProcessPID(&iTunesPSN, &pid) == noErr) { int trackPlayingIndex = [[self runScriptAndReturnResult:@"return index of current track"] intValue]; + if (trackPlayingIndex != curTrackIndex) { [self updateMenu]; curTrackIndex = trackPlayingIndex; } - + //Update Play/Pause menu item if (playPauseMenuItem) {