Alex's memory leak fixes and timeout changes.
[ITFoundation.git] / ITLoginItem.m
index f2f9e19..05a16b0 100755 (executable)
@@ -22,25 +22,23 @@ void ITSetApplicationLaunchOnLogin(NSString *path, BOOL flag)
     ITDebugLog(@"Set if \"%@\" launches at login to %i.", path, flag);
     [df synchronize];
     loginwindow = [[df persistentDomainForName:@"loginwindow"] mutableCopy];
-    loginarray = [loginwindow objectForKey:@"AutoLaunchedApplicationDictionary"];
+    loginarray = [[loginwindow objectForKey:@"AutoLaunchedApplicationDictionary"] mutableCopy];
     
     if (flag) {
-        FSRef fileRef;
+        /*FSRef fileRef;
         AliasHandle alias;
         NSData *aliasData;
         FSPathMakeRef([path UTF8String], &fileRef, NULL);
         FSNewAlias(NULL, &fileRef, &alias);
-        aliasData = [NSData dataWithBytes:&alias length:GetHandleSize((Handle)alias)];
+        aliasData = [NSData dataWithBytes:&alias length:GetHandleSize((Handle)alias)];*/
         
         if (!loginarray) { //If there is no loginarray of autolaunch items, create one
             loginarray = [[[NSMutableArray alloc] init] autorelease];
-            [loginwindow setObject:loginarray forKey:@"AutoLaunchedApplicationDictionary"];
         }
-        
         NSDictionary *itemDict = [NSDictionary dictionaryWithObjectsAndKeys:
-        [[NSBundle mainBundle] bundlePath], @"Path",
-        [NSNumber numberWithInt:0], @"Hide",
-        aliasData, @"AliasData", nil, nil];
+            [[NSBundle mainBundle] bundlePath], @"Path",
+            [NSNumber numberWithInt:0], @"Hide",
+            [NSData data], @"AliasData", nil, nil];
         [loginarray addObject:itemDict];
     } else {
         int i;
@@ -52,9 +50,11 @@ void ITSetApplicationLaunchOnLogin(NSString *path, BOOL flag)
             }
         }
     }
+    [loginwindow setObject:loginarray forKey:@"AutoLaunchedApplicationDictionary"];
     [df setPersistentDomain:loginwindow forName:@"loginwindow"];
     [df synchronize];
     [loginwindow release];
+    [loginarray release];
 }
 
 BOOL ITDoesApplicationLaunchOnLogin(NSString *path)