Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash fixes #25

Merged
merged 2 commits into from
Oct 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions MFCore/MFCore.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@
BOOL mfcGetStateOfLoginItemWithPath(NSString *path) {
UInt32 seedValue;
LSSharedFileListRef loginItemsRef = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
NSArray *loginItems = (__bridge NSArray *)(LSSharedFileListCopySnapshot(loginItemsRef, &seedValue));
CFArrayRef loginItems = LSSharedFileListCopySnapshot(loginItemsRef, &seedValue);
BOOL present = FALSE;
for(id loginItem in loginItems) {
CFIndex arrayCount = CFArrayGetCount(loginItems);
for(CFIndex i = 0; i < arrayCount; ++i) {
CFURLRef urlRef;
LSSharedFileListItemRef itemRef = (__bridge LSSharedFileListItemRef)loginItem;
LSSharedFileListItemRef itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(loginItems, i);
LSSharedFileListItemResolve(itemRef, 0, &urlRef, NULL);
NSURL *theURL = (__bridge NSURL*) urlRef;
present = [[theURL path] isEqualToString:path];
Expand All @@ -86,7 +87,7 @@ BOOL mfcGetStateOfLoginItemWithPath(NSString *path) {
}
}
CFRelease(loginItemsRef);
CFRelease((__bridge CFTypeRef)(loginItems));
CFRelease(loginItems);
return present;
}

Expand All @@ -103,10 +104,11 @@ BOOL mfcSetStateForAgentLoginItem(BOOL state) {

UInt32 seedValue;
LSSharedFileListRef loginItemsRef = LSSharedFileListCreate(NULL, kLSSharedFileListSessionLoginItems, NULL);
NSArray *loginItems = (__bridge NSArray *)LSSharedFileListCopySnapshot(loginItemsRef, &seedValue);
for(id loginItem in loginItems) {
CFArrayRef loginItems = LSSharedFileListCopySnapshot(loginItemsRef, &seedValue);
CFIndex arrayCount = CFArrayGetCount(loginItems);
for(CFIndex i = 0; i < arrayCount; ++i) {
CFURLRef urlRef;
LSSharedFileListItemRef itemRef = (__bridge LSSharedFileListItemRef)loginItem;
LSSharedFileListItemRef itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(loginItems, i);
LSSharedFileListItemResolve(itemRef, 0, &urlRef, NULL);
NSURL *theURL = (__bridge NSURL*) urlRef;
NSString* checkPath = [[theURL path] lastPathComponent];
Expand All @@ -121,7 +123,7 @@ BOOL mfcSetStateForAgentLoginItem(BOOL state) {
(__bridge CFURLRef)[NSURL fileURLWithPath: agentPath], NULL, NULL);
}
CFRelease(loginItemsRef);
CFRelease((__bridge CFTypeRef)(loginItems));
CFRelease(loginItems);
return YES;
}

Expand Down
3 changes: 2 additions & 1 deletion MFCore/MFFilesystemController.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ @implementation MFFilesystemController
#pragma mark Init and Singleton methods
+ (MFFilesystemController *)sharedController {
if (sharedController == nil) {
sharedController = [[self alloc] init];
sharedController = [self alloc];
[sharedController init];
}

return sharedController;
Expand Down