Note that there are some explanatory texts on larger screens.

plurals
  1. POleaks enabling and disabling runAtStartupEnabled
    text
    copied!<p>I just wanted to ask if you see some leaks here:</p> <pre><code>+ (BOOL)runAtStartupEnabled { NSURL *itemURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]; Boolean foundIt=false; LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL); if (loginItems) { UInt32 seed = 0U; NSArray *currentLoginItems = [NSMakeCollectable(LSSharedFileListCopySnapshot(loginItems, &amp;seed)) autorelease]; for (id itemObject in currentLoginItems) { LSSharedFileListItemRef item = (LSSharedFileListItemRef)itemObject; UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes; CFURLRef URL = NULL; OSStatus err = LSSharedFileListItemResolve(item, resolutionFlags, &amp;URL, NULL); if (err == noErr) { foundIt = CFEqual(URL, itemURL); CFRelease(URL); if (foundIt) { break; } } } CFRelease(loginItems); } return (BOOL)foundIt; } + (void)setRunAtStartupEnabled:(BOOL)enabled { NSURL *itemURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]; LSSharedFileListItemRef existingItem = NULL; LSSharedFileListRef loginItems = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL); if(loginItems) { UInt32 seed = 0U; NSArray *currentLoginItems = [NSMakeCollectable(LSSharedFileListCopySnapshot(loginItems, &amp;seed)) autorelease]; for (id itemObject in currentLoginItems) { LSSharedFileListItemRef item = (LSSharedFileListItemRef)itemObject; UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes; CFURLRef URL = NULL; OSStatus err = LSSharedFileListItemResolve(item, resolutionFlags, &amp;URL, NULL); if (err == noErr) { Boolean foundIt = CFEqual(URL, itemURL); CFRelease(URL); if (foundIt) { existingItem = item; break; } } } if (enabled &amp;&amp; (existingItem == NULL)) { LSSharedFileListInsertItemURL(loginItems, kLSSharedFileListItemBeforeFirst, NULL, NULL, (CFURLRef)itemURL, NULL, NULL); } else if(!enabled &amp;&amp; (existingItem != NULL)) { LSSharedFileListItemRemove(loginItems, existingItem); } CFRelease(loginItems); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload