diff options
author | ritsuka <[email protected]> | 2013-10-15 11:36:51 +0000 |
---|---|---|
committer | ritsuka <[email protected]> | 2013-10-15 11:36:51 +0000 |
commit | edc929027efbdade94a7e1c895308df8d058086b (patch) | |
tree | 6a1dd18b796c22d827e525457095ab26d2b09269 /macosx/Controller.m | |
parent | 186685f0ab2f2db4e37d50e8291ef8997153d831 (diff) |
MacGUI: fixed a number of leaks/null-deferences/dead-code found by clang static analyzer.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5838 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/Controller.m')
-rw-r--r-- | macosx/Controller.m | 88 |
1 files changed, 29 insertions, 59 deletions
diff --git a/macosx/Controller.m b/macosx/Controller.m index c1c53be90..9900607ff 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -109,6 +109,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It NSImageView *iv = [[NSImageView alloc] init]; [iv setImage:[[NSApplication sharedApplication] applicationIconImage]]; [dockTile setContentView:iv]; + [iv release]; /* We can move the specific values out from here by subclassing NSDockTile and package everything in here */ /* If colors are to be chosen once and for all, we can also remove the instantiation with numerical values */ @@ -146,7 +147,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It if (filenames.count == 1 && [[filenames objectAtIndex:0] isEqual:@"YES"]) return; - NSMutableArray* filesList = [[NSMutableArray alloc] initWithArray:filenames]; + NSMutableArray *filesList = [[[NSMutableArray alloc] initWithArray:filenames] autorelease]; [filesList removeObject:@"YES"]; // For now, we just want to accept one file at a time @@ -855,9 +856,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It { /* Update UI for fHandle (user scanning instance of libhb ) */ - - hb_list_t * list; - list = hb_get_titles( fHandle ); + /* check to see if there has been a new scan done this bypasses the constraints of HB_STATE_WORKING not allowing setting a newly scanned source */ @@ -1004,11 +1003,9 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It case HB_STATE_SEARCHING: { - NSMutableString * string; - NSString * pass_desc; - + NSMutableString *string; + /* Update text field */ - pass_desc = @""; //string = [NSMutableString stringWithFormat: // NSLocalizedString( @"Searching for start point: pass %d %@ of %d, %.2f %%", @"" ), // p.job_cur, pass_desc, p.job_count, 100.0 * p.progress]; @@ -1296,6 +1293,8 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It { [[NSUserDefaults standardUserDefaults] removeObjectForKey:dragDropFiles]; } + + [filesList release]; } } } @@ -1697,8 +1696,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"] ) { /*On Screen Notification*/ - int status; - status = NSRunAlertPanel(@"Put down that cocktail…",@"Your HandBrake queue is done!", @"OK", nil, nil); + NSRunAlertPanel(@"Put down that cocktail…",@"Your HandBrake queue is done!", @"OK", nil, nil); [NSApp requestUserAttention:NSCriticalRequest]; } @@ -1706,11 +1704,10 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It if( [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Put Computer To Sleep"] ) { /* Sleep */ - NSDictionary* errorDict; - NSAppleEventDescriptor* returnDescriptor = nil; - NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource: + NSDictionary *errorDict; + NSAppleScript *scriptObject = [[NSAppleScript alloc] initWithSource: @"tell application \"Finder\" to sleep"]; - returnDescriptor = [scriptObject executeAndReturnError: &errorDict]; + [scriptObject executeAndReturnError: &errorDict]; [scriptObject release]; } /* If Shutdown has been selected */ @@ -1718,10 +1715,9 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It { /* Shut Down */ NSDictionary* errorDict; - NSAppleEventDescriptor* returnDescriptor = nil; NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource: @"tell application \"Finder\" to shut down"]; - returnDescriptor = [scriptObject executeAndReturnError: &errorDict]; + [scriptObject executeAndReturnError: &errorDict]; [scriptObject release]; } } @@ -2185,7 +2181,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It } /* if we are a stream, select the first title */ - if (title->type == HB_STREAM_TYPE || title->type == HB_FF_STREAM_TYPE) + if (title && (title->type == HB_STREAM_TYPE || title->type == HB_FF_STREAM_TYPE)) { [fSrcTitlePopUp selectItemAtIndex: 0]; } @@ -2326,6 +2322,8 @@ static void queueFSEventStreamCallback( kFSEventStreamCreateFlagIgnoreSelf ); + CFRelease(pathsToWatch); + /* Create the stream before calling this. */ FSEventStreamScheduleWithRunLoop(QueueStream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); FSEventStreamStart(QueueStream); @@ -2859,8 +2857,6 @@ fWorkingCount = 0; [QueueFileArray removeObjectAtIndex:removeIndex]; [QueueFileArray insertObject:object atIndex:insertIndex]; [object release]; - - index = [indexSet indexLessThanIndex:index]; /* We save all of the Queue data here * and it also gets sent back to the queue controller*/ @@ -2932,7 +2928,6 @@ fWorkingCount = 0; * settings as this is a queue rescan */ NSString *path = scanPath; - HBDVDDetector *detector = [HBDVDDetector detectorForPath:path]; if (cancelScanDecrypt == 0) { @@ -6233,21 +6228,6 @@ the user is using "Custom" settings by determining the sender*/ /* We use this to determine if an item should be expandable */ - (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item { - - /* we need to return the count of the array in ChildrenArray for this folder */ - NSArray *children= nil; - if (item == nil) - { - children = UserPresets; - } - else - { - if ([item objectForKey:@"ChildrenArray"]) - { - children = [item objectForKey:@"ChildrenArray"]; - } - } - /* To deterimine if an item should show a disclosure triangle * we could do it by the children count as so: * if ([children count] < 1) @@ -6257,15 +6237,14 @@ the user is using "Custom" settings by determining the sender*/ */ /* We need to determine if the item is a folder */ - if ([[item objectForKey:@"Folder"] intValue] == 1) - { + if ([[item objectForKey:@"Folder"] intValue] == 1) + { return YES; } else { return NO; } - } - (BOOL)outlineView:(NSOutlineView *)outlineView shouldExpandItem:(id)item @@ -6311,14 +6290,11 @@ return YES; { NSFont *txtFont; NSColor *fontColor; - NSColor *shadowColor; txtFont = [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]; /*check to see if its a selected row */ if ([fPresetsOutlineView selectedRow] == [fPresetsOutlineView rowForItem:item]) { - fontColor = [NSColor blackColor]; - shadowColor = [NSColor colorWithDeviceRed:(127.0/255.0) green:(140.0/255.0) blue:(160.0/255.0) alpha:1.0]; } else { @@ -6460,11 +6436,9 @@ return YES; /* first, lets see if we are dropping into a folder */ if ([[fPresetsOutlineView itemAtRow:index] objectForKey:@"Folder"] && [[[fPresetsOutlineView itemAtRow:index] objectForKey:@"Folder"] intValue] == 1) // if its a folder { - NSMutableArray *childrenArray = [[NSMutableArray alloc] init]; - childrenArray = [[fPresetsOutlineView itemAtRow:index] objectForKey:@"ChildrenArray"]; - [childrenArray addObject:item]; - [[fPresetsOutlineView itemAtRow:index] setObject:[NSMutableArray arrayWithArray: childrenArray] forKey:@"ChildrenArray"]; - [childrenArray autorelease]; + NSMutableArray *childrenArray = [[fPresetsOutlineView itemAtRow:index] objectForKey:@"ChildrenArray"]; + [childrenArray addObject:item]; + [[fPresetsOutlineView itemAtRow:index] setObject:[NSMutableArray arrayWithArray: childrenArray] forKey:@"ChildrenArray"]; } else // We are not, so we just move the preset into the existing array { @@ -6505,8 +6479,6 @@ return YES; [array removeObjectAtIndex:removeIndex]; [array insertObject:object atIndex:insertIndex]; [object release]; - - index = [indexSet indexLessThanIndex:index]; } @@ -7053,9 +7025,8 @@ return YES; { /* Show an alert window that built in presets will be updated */ /*On Screen Notification*/ - int status; NSBeep(); - status = NSRunAlertPanel(@"HandBrake has determined your built in presets are out of date…",@"HandBrake will now update your built-in presets.", @"OK", nil, nil); + NSRunAlertPanel(@"HandBrake has determined your built in presets are out of date…",@"HandBrake will now update your built-in presets.", @"OK", nil, nil); [NSApp requestUserAttention:NSCriticalRequest]; } /* when alert is dismissed, go ahead and update the built in presets */ @@ -7344,6 +7315,7 @@ return YES; [preset setObject:[NSMutableArray arrayWithArray: audioListArray] forKey:@"AudioList"]; + [audioListArray release]; /* Temporarily remove subtitles from creating a new preset as it has to be converted over to use the new @@ -7446,7 +7418,7 @@ return YES; { [[NSFileManager defaultManager] createFileAtPath:exportPresetsFile contents:nil attributes:nil]; } - NSMutableArray * presetsToExport = [[NSMutableArray alloc] initWithContentsOfFile:exportPresetsFile]; + NSMutableArray *presetsToExport = [[[NSMutableArray alloc] initWithContentsOfFile:exportPresetsFile] autorelease]; if (nil == presetsToExport) { presetsToExport = [[NSMutableArray alloc] init]; @@ -7460,7 +7432,6 @@ return YES; [presetsToExport writeToFile:exportPresetsFile atomically:YES]; } - } } @@ -7688,7 +7659,6 @@ return YES; NSMutableArray *presetsArrayToMod; - NSMutableArray *tempArray; /* If we are a root level preset, we are modding the UserPresets array */ if (presetToModLevel == 0) @@ -7701,7 +7671,6 @@ return YES; } enumerator = [presetsArrayToMod objectEnumerator]; - tempArray = [NSMutableArray array]; int iiii = 0; while (tempObject = [enumerator nextObject]) { @@ -7840,16 +7809,17 @@ return YES; - (void) browseForChapterFileDone: (NSOpenPanel *) sheet returnCode: (int) returnCode contextInfo: (void *) contextInfo { - NSArray *chaptersArray; /* temp array for chapters */ - NSMutableArray *chaptersMutableArray; /* temp array for chapters */ - NSString *chapterName; /* temp string from file */ + NSArray *chaptersArray = nil; /* temp array for chapters */ + NSMutableArray *chaptersMutableArray = nil; /* temp array for chapters */ + NSString *chapterName = nil; /* temp string from file */ int chapters, i; if( returnCode == NSOKButton ) /* if they click OK */ { chapterName = [[NSString alloc] initWithContentsOfFile:[sheet filename] encoding:NSUTF8StringEncoding error:NULL]; chaptersArray = [chapterName componentsSeparatedByString:@"\n"]; - chaptersMutableArray= [chaptersArray mutableCopy]; + [chapterName release]; + chaptersMutableArray = [[chaptersArray mutableCopy] autorelease]; chapters = [fChapterTitlesDelegate numberOfRowsInTableView:fChapterTable]; if ([chaptersMutableArray count] > 0) { @@ -7922,7 +7892,7 @@ return YES; { NSString *chapterName; /* pointer for string for later file-writing */ NSString *chapterTitle; - NSError *saveError = [[NSError alloc] init]; + NSError *saveError = nil; int chapters, i; /* ints for the number of chapters in the table and the loop */ if( returnCode == NSOKButton ) /* if they clicked OK */ |