Fixed a memory leak which would occur on every application switch.

CQTexperiment
Chris Moeller 2016-06-28 19:31:55 -07:00
parent 98f0757089
commit 64c401b5d8
1 changed files with 11 additions and 5 deletions

View File

@ -271,12 +271,18 @@ NSString *kIgnoreMediaKeysDefaultsKey = @"SPIgnoreMediaKeys";
-(void)appIsNowFrontmost:(ProcessSerialNumber)psn; -(void)appIsNowFrontmost:(ProcessSerialNumber)psn;
{ {
NSValue *psnv = [NSValue valueWithBytes:&psn objCType:@encode(ProcessSerialNumber)]; NSValue *psnv = [NSValue valueWithBytes:&psn objCType:@encode(ProcessSerialNumber)];
NSDictionary *processInfo = (__bridge id)ProcessInformationCopyDictionary( CFDictionaryRef cfDict = ProcessInformationCopyDictionary(
&psn, &psn,
kProcessDictionaryIncludeAllInformationMask kProcessDictionaryIncludeAllInformationMask
); );
if (!cfDict) return;
NSDictionary *processInfo = (__bridge id)cfDict;
NSString *bundleIdentifier = [processInfo objectForKey:(id)kCFBundleIdentifierKey]; NSString *bundleIdentifier = [processInfo objectForKey:(id)kCFBundleIdentifierKey];
CFRelease(cfDict);
NSArray *whitelistIdentifiers = [[NSUserDefaults standardUserDefaults] arrayForKey:kMediaKeyUsingBundleIdentifiersDefaultsKey]; NSArray *whitelistIdentifiers = [[NSUserDefaults standardUserDefaults] arrayForKey:kMediaKeyUsingBundleIdentifiersDefaultsKey];
if(![whitelistIdentifiers containsObject:bundleIdentifier]) return; if(![whitelistIdentifiers containsObject:bundleIdentifier]) return;