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
This commit is contained in:
ritsuka 2013-10-15 11:36:51 +00:00
parent 186685f0ab
commit edc929027e
14 changed files with 210 additions and 214 deletions

View File

@ -19,7 +19,7 @@
- (NSArray*)chapterTitlesArray;
// Table View Delegates
- (int)numberOfRowsInTableView:(NSTableView *)aTableView;
- (NSUInteger)numberOfRowsInTableView:(NSTableView *)aTableView;
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn

View File

@ -59,7 +59,7 @@
return [NSArray arrayWithArray:fChapterTitlesArray];
}
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
- (NSUInteger)numberOfRowsInTableView:(NSTableView *)aTableView
{
if (fTitle == NULL)
{
@ -91,7 +91,7 @@
{
if ([[aTableColumn identifier] intValue] == 1)
{
return [NSString stringWithFormat:@"%d", rowIndex + 1];
return [NSString stringWithFormat:@"%ld", rowIndex + 1];
}
else if (fTitle != NULL)
{

View File

@ -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 */

View File

@ -10,9 +10,11 @@
- (id)init
{
[super init];
[self loadMyNibFile];
if( self = [super init] )
{
[self loadMyNibFile];
}
return self;
}

View File

@ -110,7 +110,7 @@ static NSMutableArray *masterBitRateArray = nil;
// sample rate depends on the track, which means it depends on the title, so cannot be nicely set up here.
masterSampleRateArray = [[NSMutableArray alloc] init]; // knowingly leaked
[masterSampleRateArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithString:@"Auto"], keyAudioSampleRateName,
@"Auto", keyAudioSampleRateName,
[NSNumber numberWithInt:0], keyAudioSamplerate,
nil]];
for (const hb_rate_t *audio_samplerate = hb_audio_samplerate_get_next(NULL);
@ -142,7 +142,7 @@ static NSMutableArray *masterBitRateArray = nil;
{
NSMutableArray *permittedCodecs = [NSMutableArray array];
unsigned int count = [masterCodecArray count];
NSUInteger count = [masterCodecArray count];
NSDictionary *dict;
// First get a list of the permitted codecs based on the internal rules
@ -199,7 +199,7 @@ static NSMutableArray *masterBitRateArray = nil;
int currentMixdown;
unsigned long long channelLayout = [[track objectForKey: keyAudioInputChannelLayout] unsignedLongLongValue];
unsigned int count = [masterMixdownArray count];
NSUInteger count = [masterMixdownArray count];
int codecCodec = [[codec objectForKey: keyAudioCodec] intValue];
int theDefaultMixdown = hb_mixdown_get_default(codecCodec, channelLayout);
@ -245,7 +245,7 @@ static NSMutableArray *masterBitRateArray = nil;
int currentBitRate;
BOOL shouldAdd;
unsigned int count = [masterBitRateArray count];
NSUInteger count = [masterBitRateArray count];
int trackInputBitRate = [[[self track] objectForKey: keyAudioInputBitrate] intValue];
int theSampleRate = [[[self sampleRate] objectForKey: keyAudioSamplerate] intValue];
@ -279,7 +279,7 @@ static NSMutableArray *masterBitRateArray = nil;
else if (codecIsLossless)
{
NSDictionary *bitRateNotApplicable = [NSDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithString: @"N/A"], keyAudioBitrateName,
@"N/A", keyAudioBitrateName,
[NSNumber numberWithInt: -1], keyAudioBitrate,
nil];
[permittedBitRates addObject: bitRateNotApplicable];

View File

@ -48,9 +48,9 @@ extern NSString *HBMixdownChangedNotification;
@interface HBAudioController (KVC)
- (unsigned int) countOfAudioArray;
- (HBAudio *) objectInAudioArrayAtIndex: (unsigned int) index;
- (void) insertObject: (HBAudio *) audioObject inAudioArrayAtIndex: (unsigned int) index;
- (void) removeObjectFromAudioArrayAtIndex: (unsigned int) index;
- (NSUInteger) countOfAudioArray;
- (HBAudio *) objectInAudioArrayAtIndex: (NSUInteger) index;
- (void) insertObject: (HBAudio *) audioObject inAudioArrayAtIndex: (NSUInteger) index;
- (void) removeObjectFromAudioArrayAtIndex: (NSUInteger) index;
@end

View File

@ -83,13 +83,13 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
- (void) prepareAudioForQueueFileJob: (NSMutableDictionary *) aDict
{
unsigned int audioArrayCount = [self countOfAudioArray];
for (unsigned int counter = 0; counter < audioArrayCount; counter++)
NSUInteger audioArrayCount = [self countOfAudioArray];
for (NSUInteger counter = 0; counter < audioArrayCount; counter++)
{
HBAudio *anAudio = [self objectInAudioArrayAtIndex: counter];
if ([anAudio enabled])
{
NSString *prefix = [NSString stringWithFormat: @"Audio%d", counter + 1];
NSString *prefix = [NSString stringWithFormat: @"Audio%lu", counter + 1];
NSNumber *sampleRateToUse = ([[[anAudio sampleRate] objectForKey: keyAudioSamplerate] intValue] == 0 ?
[[anAudio track] objectForKey: keyAudioInputSampleRate] :
[[anAudio sampleRate] objectForKey: keyAudioSamplerate]);
@ -123,7 +123,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
[aDict setObject: [NSNumber numberWithInt:0] forKey: [prefix stringByAppendingString: @"TrackDRCSlider"]];
}
prefix = [NSString stringWithFormat: @"JobAudio%d", counter + 1];
prefix = [NSString stringWithFormat: @"JobAudio%lu", counter + 1];
[aDict setObject: [[anAudio codec] objectForKey: keyAudioCodec] forKey: [prefix stringByAppendingString: @"Encoder"]];
[aDict setObject: [[anAudio mixdown] objectForKey: keyAudioMixdown] forKey: [prefix stringByAppendingString: @"Mixdown"]];
[aDict setObject: sampleRateToUse forKey: [prefix stringByAppendingString: @"Samplerate"]];
@ -147,7 +147,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
}
// Now add audio tracks based on the current settings
unsigned int audioArrayCount = [self countOfAudioArray];
NSUInteger audioArrayCount = [self countOfAudioArray];
for (i = 0; i < audioArrayCount; i++)
{
HBAudio *anAudio = [self objectInAudioArrayAtIndex:i];
@ -181,8 +181,8 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
- (void) prepareAudioForPreset: (NSMutableArray *) anArray
{
unsigned int audioArrayCount = [self countOfAudioArray];
unsigned int i;
NSUInteger audioArrayCount = [self countOfAudioArray];
NSUInteger i;
for (i = 0; i < audioArrayCount; i++)
{
@ -364,7 +364,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
{
unsigned int retval = defaultIfNotFound;
int count = [masterTrackArray count];
NSUInteger count = [masterTrackArray count];
NSString *languageTitle;
BOOL found = NO;
@ -436,7 +436,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
// If all tracks should be added, add all track numbers that are not yet processed
if (allTracks)
{
unsigned int count = [masterTrackArray count];
NSUInteger count = [masterTrackArray count];
for (unsigned int i = 1; i < count; i++)
{
NSNumber *trackNumber = [NSNumber numberWithInt:i];
@ -454,12 +454,13 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
{
[self _processPresetAudioArray: whatToUse forTrack:[trackNumber intValue] andType: [[aPreset objectForKey: @"Type"] intValue]];
}
[tracksToAdd release];
}
- (void) _ensureAtLeastOneNonEmptyTrackExists
{
int count = [self countOfAudioArray];
NSUInteger count = [self countOfAudioArray];
if (0 == count || ![[self objectInAudioArrayAtIndex: 0] enabled])
{
[self addTracksFromPreset: [self _defaultPreset] allTracks: NO];
@ -485,8 +486,8 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
{
BOOL retval = NO;
unsigned int audioArrayCount = [self countOfAudioArray];
for (unsigned int i = 0; i < audioArrayCount && !retval; i++)
NSUInteger audioArrayCount = [self countOfAudioArray];
for (NSUInteger i = 0; i < audioArrayCount && !retval; i++)
{
HBAudio *anAudio = [self objectInAudioArrayAtIndex: i];
if ([anAudio enabled] && aCodecValue == [[[anAudio codec] objectForKey: keyAudioCodec] intValue])
@ -531,7 +532,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
- (void) switchingTrackFromNone: (HBAudio *) noLongerNoneTrack
{
int count = [self countOfAudioArray];
NSUInteger count = [self countOfAudioArray];
BOOL needToAdd = NO;
int maximumNumberOfAllowedAudioTracks = [HBController maximumNumberOfAllowedAudioTracks];
@ -626,25 +627,25 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
#pragma mark -
#pragma mark KVC
- (unsigned int) countOfAudioArray
- (NSUInteger) countOfAudioArray
{
return [audioArray count];
}
- (HBAudio *) objectInAudioArrayAtIndex: (unsigned int) index
- (HBAudio *) objectInAudioArrayAtIndex: (NSUInteger) index
{
return [audioArray objectAtIndex: index];
}
- (void) insertObject: (HBAudio *) audioObject inAudioArrayAtIndex: (unsigned int) index;
- (void) insertObject: (HBAudio *) audioObject inAudioArrayAtIndex: (NSUInteger) index;
{
[audioArray insertObject: audioObject atIndex: index];
}
- (void) removeObjectFromAudioArrayAtIndex: (unsigned int) index
- (void) removeObjectFromAudioArrayAtIndex: (NSUInteger) index
{
[audioArray removeObjectAtIndex: index];

View File

@ -5,7 +5,7 @@
#import <Cocoa/Cocoa.h>
@interface HBPreferencesController : NSWindowController
@interface HBPreferencesController : NSWindowController <NSToolbarDelegate>
{
IBOutlet NSView * fGeneralView, * fPictureView, * fAudioView, * fAdvancedView;
IBOutlet NSTextField * fSendEncodeToAppField;

View File

@ -207,7 +207,8 @@
[audioListArray addObject:audioTrack2Array];
/* Add the audio track(s) to the preset's audio list */
[preset setObject:[NSMutableArray arrayWithArray:audioListArray] forKey:@"AudioList"];
[audioListArray release];
/* Subtitles (note: currently ignored) */
[preset setObject:@"None" forKey:@"Subtitles"];
@ -311,7 +312,8 @@
[audioListArray addObject:audioTrack1Array];
/* Add the audio track(s) to the preset's audio list */
[preset setObject:[NSMutableArray arrayWithArray:audioListArray] forKey:@"AudioList"];
[audioListArray release];
/* Subtitles (note: currently ignored) */
[preset setObject:@"None" forKey:@"Subtitles"];
@ -415,7 +417,8 @@
[audioListArray addObject:audioTrack1Array];
/* Add the audio track(s) to the preset's audio list */
[preset setObject:[NSMutableArray arrayWithArray:audioListArray] forKey:@"AudioList"];
[audioListArray release];
/* Subtitles (note: currently ignored) */
[preset setObject:@"None" forKey:@"Subtitles"];
@ -519,7 +522,8 @@
[audioListArray addObject:audioTrack1Array];
/* Add the audio track(s) to the preset's audio list */
[preset setObject:[NSMutableArray arrayWithArray:audioListArray] forKey:@"AudioList"];
[audioListArray release];
/* Subtitles (note: currently ignored) */
[preset setObject:@"None" forKey:@"Subtitles"];
@ -635,7 +639,8 @@
[audioListArray addObject:audioTrack2Array];
/* Add the audio track(s) to the preset's audio list */
[preset setObject:[NSMutableArray arrayWithArray:audioListArray] forKey:@"AudioList"];
[audioListArray release];
/* Subtitles (note: currently ignored) */
[preset setObject:@"None" forKey:@"Subtitles"];
@ -750,7 +755,8 @@
[audioListArray addObject:audioTrack2Array];
/* Add the audio track(s) to the preset's audio list */
[preset setObject:[NSMutableArray arrayWithArray:audioListArray] forKey:@"AudioList"];
[audioListArray release];
/* Subtitles (note: currently ignored) */
[preset setObject:@"None" forKey:@"Subtitles"];
@ -865,7 +871,8 @@
[audioListArray addObject:audioTrack2Array];
/* Add the audio track(s) to the preset's audio list */
[preset setObject:[NSMutableArray arrayWithArray:audioListArray] forKey:@"AudioList"];
[audioListArray release];
/* Subtitles (note: currently ignored) */
[preset setObject:@"None" forKey:@"Subtitles"];
@ -969,7 +976,8 @@
[audioListArray addObject:audioTrack1Array];
/* Add the audio track(s) to the preset's audio list */
[preset setObject:[NSMutableArray arrayWithArray:audioListArray] forKey:@"AudioList"];
[audioListArray release];
/* Subtitles (note: currently ignored) */
[preset setObject:@"None" forKey:@"Subtitles"];
@ -1073,6 +1081,7 @@
[audioListArray addObject:audioTrack1Array];
/* Add the audio track(s) to the preset's audio list */
[preset setObject:[NSMutableArray arrayWithArray:audioListArray] forKey:@"AudioList"];
[audioListArray release];
/* Subtitles (note: currently ignored) */
[preset setObject:@"None" forKey:@"Subtitles"];
@ -1177,7 +1186,8 @@
[audioListArray addObject:audioTrack1Array];
/* Add the audio track(s) to the preset's audio list */
[preset setObject:[NSMutableArray arrayWithArray:audioListArray] forKey:@"AudioList"];
[audioListArray release];
/* Subtitles (note: currently ignored) */
[preset setObject:@"None" forKey:@"Subtitles"];
@ -1281,7 +1291,8 @@
[audioListArray addObject:audioTrack1Array];
/* Add the audio track(s) to the preset's audio list */
[preset setObject:[NSMutableArray arrayWithArray:audioListArray] forKey:@"AudioList"];
[audioListArray release];
/* Subtitles (note: currently ignored) */
[preset setObject:@"None" forKey:@"Subtitles"];
@ -1396,7 +1407,8 @@
[audioListArray addObject:audioTrack2Array];
/* Add the audio track(s) to the preset's audio list */
[preset setObject:[NSMutableArray arrayWithArray:audioListArray] forKey:@"AudioList"];
[audioListArray release];
/* Subtitles (note: currently ignored) */
[preset setObject:@"None" forKey:@"Subtitles"];

View File

@ -48,7 +48,7 @@ BOOL fIsDragging;
@interface HBQueueController : NSWindowController <NSToolbarDelegate>
@interface HBQueueController : NSWindowController <NSToolbarDelegate, NSWindowDelegate>
{
hb_handle_t *fQueueEncodeLibhb; // reference to libhb
HBController *fHBController; // reference to HBController
@ -106,7 +106,14 @@ BOOL fIsDragging;
IBOutlet NSSlider *fSpacing; // debug
#endif
// Text Styles
NSMutableParagraphStyle *ps;
NSDictionary *detailAttr;
NSDictionary *detailBoldAttr;
NSDictionary *titleAttr;
NSDictionary *shortHeightAttr;
}
- (void)setPidNum: (int)myPidnum;
- (void)setHandle: (hb_handle_t *)handle;
- (void)setHBController: (HBController *)controller;

View File

@ -109,9 +109,11 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe
nil]];
fJobGroups = [[NSMutableArray arrayWithCapacity:0] retain];
}
return self;
[self initStyles];
}
return self;
}
- (void)setQueueArray: (NSMutableArray *)QueueFileArray
@ -211,6 +213,12 @@ static NSString* HBQueuePauseResumeToolbarIdentifier = @"HBQueuePauseRe
[fSavedExpandedItems release];
[fSavedSelectedItems release];
[ps release];
[detailAttr release];
[detailBoldAttr release];
[titleAttr release];
[shortHeightAttr release];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
@ -822,40 +830,42 @@ return ![(HBQueueOutlineView*)outlineView isDragging];
}
}
- (void)initStyles
{
// Attributes
ps = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain];
[ps setHeadIndent: 40.0];
[ps setParagraphSpacing: 1.0];
[ps setTabStops:[NSArray array]]; // clear all tabs
[ps addTabStop: [[[NSTextTab alloc] initWithType: NSLeftTabStopType location: 20.0] autorelease]];
detailAttr = [[NSDictionary dictionaryWithObjectsAndKeys:
[NSFont systemFontOfSize:10.0], NSFontAttributeName,
ps, NSParagraphStyleAttributeName,
nil] retain];
detailBoldAttr = [[NSDictionary dictionaryWithObjectsAndKeys:
[NSFont boldSystemFontOfSize:10.0], NSFontAttributeName,
ps, NSParagraphStyleAttributeName,
nil] retain];
titleAttr = [[NSDictionary dictionaryWithObjectsAndKeys:
[NSFont systemFontOfSize:[NSFont systemFontSize]], NSFontAttributeName,
ps, NSParagraphStyleAttributeName,
nil] retain];
shortHeightAttr = [[NSDictionary dictionaryWithObjectsAndKeys:
[NSFont systemFontOfSize:2.0], NSFontAttributeName,
nil] retain];
}
- (id)outlineView:(NSOutlineView *)fOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
if ([[tableColumn identifier] isEqualToString:@"desc"])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
/* Below should be put into a separate method but I am way too f'ing lazy right now */
NSMutableAttributedString * finalString = [[[NSMutableAttributedString alloc] initWithString: @""] autorelease];
// Attributes
NSMutableParagraphStyle * ps = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] retain];
[ps setHeadIndent: 40.0];
[ps setParagraphSpacing: 1.0];
[ps setTabStops:[NSArray array]]; // clear all tabs
[ps addTabStop: [[[NSTextTab alloc] initWithType: NSLeftTabStopType location: 20.0] autorelease]];
NSDictionary* detailAttr = [NSDictionary dictionaryWithObjectsAndKeys:
[NSFont systemFontOfSize:10.0], NSFontAttributeName,
ps, NSParagraphStyleAttributeName,
nil];
NSDictionary* detailBoldAttr = [NSDictionary dictionaryWithObjectsAndKeys:
[NSFont boldSystemFontOfSize:10.0], NSFontAttributeName,
ps, NSParagraphStyleAttributeName,
nil];
NSDictionary* titleAttr = [NSDictionary dictionaryWithObjectsAndKeys:
[NSFont systemFontOfSize:[NSFont systemFontSize]], NSFontAttributeName,
ps, NSParagraphStyleAttributeName,
nil];
NSDictionary* shortHeightAttr = [NSDictionary dictionaryWithObjectsAndKeys:
[NSFont systemFontOfSize:2.0], NSFontAttributeName,
nil];
NSMutableAttributedString * finalString = [[NSMutableAttributedString alloc] initWithString: @""];
/* First line, we should strip the destination path and just show the file name and add the title num and chapters (if any) */
NSString * summaryInfo;
@ -1214,9 +1224,11 @@ return ![(HBQueueOutlineView*)outlineView isDragging];
[finalString appendString:@"\n" withAttributes:detailAttr];
}
i++;
}
return finalString;
}
[pool release];
return [finalString autorelease];
}
else if ([[tableColumn identifier] isEqualToString:@"icon"])
{

View File

@ -10,14 +10,14 @@
@interface HBSubtitles : NSObject {
@interface HBSubtitles : NSObject <NSTableViewDataSource> {
hb_title_t *fTitle;
NSMutableArray *subtitleArray; // contains the output subtitle track info
NSMutableArray *subtitleSourceArray;// contains the source subtitle track info
NSString *foreignAudioSearchTrackName;
NSMutableArray *languagesArray; // array of languages taken from lang.c
int languagesArrayDefIndex;
NSInteger languagesArrayDefIndex;
NSMutableArray *charCodeArray; // array of character codes
int charCodeArrayDefIndex;
int container;
@ -39,7 +39,7 @@ int container;
- (void)setNewSubtitles:(NSMutableArray*) newSubtitleArray;
// Table View Delegates
- (int)numberOfRowsInTableView:(NSTableView *)aTableView;
- (NSUInteger)numberOfRowsInTableView:(NSTableView *)aTableView;
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn

View File

@ -11,66 +11,66 @@
@implementation HBSubtitles
- (id)init
{
self = [super init];
if( self != nil )
if( self = [super init] )
{
fTitle = NULL;
}
/* setup our array of languages */
const iso639_lang_t *lang;
languagesArray = [[NSMutableArray alloc] init];
for (lang = lang_get_next(NULL); lang != NULL; lang = lang_get_next(lang))
{
[languagesArray addObject:[NSArray arrayWithObjects:
[NSString stringWithUTF8String:lang->eng_name],
[NSString stringWithUTF8String:lang->iso639_2],
nil]];
if (!strcasecmp(lang->eng_name, "English"))
/* setup our array of languages */
const iso639_lang_t *lang;
languagesArray = [[NSMutableArray alloc] init];
for (lang = lang_get_next(NULL); lang != NULL; lang = lang_get_next(lang))
{
languagesArrayDefIndex = [languagesArray count] - 1;
[languagesArray addObject:[NSArray arrayWithObjects:
[NSString stringWithUTF8String:lang->eng_name],
[NSString stringWithUTF8String:lang->iso639_2],
nil]];
if (!strcasecmp(lang->eng_name, "English"))
{
languagesArrayDefIndex = [languagesArray count] - 1;
}
}
/* populate the charCodeArray */
charCodeArray = [[NSMutableArray alloc] init];
[charCodeArray addObject:@"ANSI_X3.4-1968"];
[charCodeArray addObject:@"ANSI_X3.4-1986"];
[charCodeArray addObject:@"ANSI_X3.4"];
[charCodeArray addObject:@"ANSI_X3.110-1983"];
[charCodeArray addObject:@"ANSI_X3.110"];
[charCodeArray addObject:@"ASCII"];
[charCodeArray addObject:@"ECMA-114"];
[charCodeArray addObject:@"ECMA-118"];
[charCodeArray addObject:@"ECMA-128"];
[charCodeArray addObject:@"ECMA-CYRILLIC"];
[charCodeArray addObject:@"IEC_P27-1"];
[charCodeArray addObject:@"ISO-8859-1"];
[charCodeArray addObject:@"ISO-8859-2"];
[charCodeArray addObject:@"ISO-8859-3"];
[charCodeArray addObject:@"ISO-8859-4"];
[charCodeArray addObject:@"ISO-8859-5"];
[charCodeArray addObject:@"ISO-8859-6"];
[charCodeArray addObject:@"ISO-8859-7"];
[charCodeArray addObject:@"ISO-8859-8"];
[charCodeArray addObject:@"ISO-8859-9"];
[charCodeArray addObject:@"ISO-8859-9E"];
[charCodeArray addObject:@"ISO-8859-10"];
[charCodeArray addObject:@"ISO-8859-11"];
[charCodeArray addObject:@"ISO-8859-13"];
[charCodeArray addObject:@"ISO-8859-14"];
[charCodeArray addObject:@"ISO-8859-15"];
[charCodeArray addObject:@"ISO-8859-16"];
[charCodeArray addObject:@"UTF-7"];
[charCodeArray addObject:@"UTF-8"];
[charCodeArray addObject:@"UTF-16"];
[charCodeArray addObject:@"UTF-16LE"];
[charCodeArray addObject:@"UTF-16BE"];
[charCodeArray addObject:@"UTF-32"];
[charCodeArray addObject:@"UTF-32LE"];
[charCodeArray addObject:@"UTF-32BE"];
charCodeArrayDefIndex = 11;
}
/* populate the charCodeArray */
charCodeArray = [[NSMutableArray alloc] init];
[charCodeArray addObject:@"ANSI_X3.4-1968"];
[charCodeArray addObject:@"ANSI_X3.4-1986"];
[charCodeArray addObject:@"ANSI_X3.4"];
[charCodeArray addObject:@"ANSI_X3.110-1983"];
[charCodeArray addObject:@"ANSI_X3.110"];
[charCodeArray addObject:@"ASCII"];
[charCodeArray addObject:@"ECMA-114"];
[charCodeArray addObject:@"ECMA-118"];
[charCodeArray addObject:@"ECMA-128"];
[charCodeArray addObject:@"ECMA-CYRILLIC"];
[charCodeArray addObject:@"IEC_P27-1"];
[charCodeArray addObject:@"ISO-8859-1"];
[charCodeArray addObject:@"ISO-8859-2"];
[charCodeArray addObject:@"ISO-8859-3"];
[charCodeArray addObject:@"ISO-8859-4"];
[charCodeArray addObject:@"ISO-8859-5"];
[charCodeArray addObject:@"ISO-8859-6"];
[charCodeArray addObject:@"ISO-8859-7"];
[charCodeArray addObject:@"ISO-8859-8"];
[charCodeArray addObject:@"ISO-8859-9"];
[charCodeArray addObject:@"ISO-8859-9E"];
[charCodeArray addObject:@"ISO-8859-10"];
[charCodeArray addObject:@"ISO-8859-11"];
[charCodeArray addObject:@"ISO-8859-13"];
[charCodeArray addObject:@"ISO-8859-14"];
[charCodeArray addObject:@"ISO-8859-15"];
[charCodeArray addObject:@"ISO-8859-16"];
[charCodeArray addObject:@"UTF-7"];
[charCodeArray addObject:@"UTF-8"];
[charCodeArray addObject:@"UTF-16"];
[charCodeArray addObject:@"UTF-16LE"];
[charCodeArray addObject:@"UTF-16BE"];
[charCodeArray addObject:@"UTF-32"];
[charCodeArray addObject:@"UTF-32LE"];
[charCodeArray addObject:@"UTF-32BE"];
charCodeArrayDefIndex = 11;
return self;
}
@ -153,8 +153,7 @@
else
{
[foreignAudioSearchTrackName release];
foreignAudioSearchTrackName = [[NSString stringWithString:@"Foreign Audio Search - (Bitmap)"]
retain];
foreignAudioSearchTrackName = @"Foreign Audio Search - (Bitmap)";
}
[forcedSourceNamesArray release];
@ -205,7 +204,7 @@
/* create a dictionary of source subtitle information to store in our array */
NSMutableDictionary *newSubtitleSourceTrack = [[NSMutableDictionary alloc] init];
/* Subtitle Source track popup index */
[newSubtitleSourceTrack setObject:[NSNumber numberWithInt:[subtitleSourceArray count]+1] forKey:@"sourceTrackNum"];
[newSubtitleSourceTrack setObject:[NSNumber numberWithInteger:[subtitleSourceArray count]+1] forKey:@"sourceTrackNum"];
/* Subtitle Source track name */
[newSubtitleSourceTrack setObject:displayname forKey:@"sourceTrackName"];
/* Subtitle Source track type (VobSub, Srt, etc.) */
@ -231,11 +230,11 @@
/* Subtitle Source track popup index */
if ([subtitleArray count] == 0) // we now have an empty array so this will be our first track
{
[newSubtitleSrtTrack setObject:[NSNumber numberWithInt:[subtitleSourceArray count] + 1] forKey:@"subtitleSourceTrackNum"];
[newSubtitleSrtTrack setObject:[NSNumber numberWithInteger:[subtitleSourceArray count] + 1] forKey:@"subtitleSourceTrackNum"];
}
else
{
[newSubtitleSrtTrack setObject:[NSNumber numberWithInt:[subtitleSourceArray count]] forKey:@"subtitleSourceTrackNum"];
[newSubtitleSrtTrack setObject:[NSNumber numberWithInteger:[subtitleSourceArray count]] forKey:@"subtitleSourceTrackNum"];
}
[newSubtitleSrtTrack setObject:[NSNumber numberWithInt:SRTSUB] forKey:@"sourceTrackType"];
@ -255,7 +254,7 @@
/* now the srt only info, Language, Chart Code and offset */
[newSubtitleSrtTrack setObject:filePath forKey:@"subtitleSourceSrtFilePath"];
[newSubtitleSrtTrack setObject:[NSNumber numberWithInt:languagesArrayDefIndex] forKey:@"subtitleTrackSrtLanguageIndex"];
[newSubtitleSrtTrack setObject:[NSNumber numberWithInteger:languagesArrayDefIndex] forKey:@"subtitleTrackSrtLanguageIndex"];
[newSubtitleSrtTrack setObject:[[languagesArray objectAtIndex:languagesArrayDefIndex] objectAtIndex:0] forKey:@"subtitleTrackSrtLanguageLong"];
[newSubtitleSrtTrack setObject:[[languagesArray objectAtIndex:languagesArrayDefIndex] objectAtIndex:1] forKey:@"subtitleTrackSrtLanguageIso3"];
@ -307,7 +306,7 @@
/* create a dictionary of source subtitle information to store in our array */
NSMutableDictionary *newSubtitleSourceTrack = [[NSMutableDictionary alloc] init];
/* Subtitle Source track popup index */
[newSubtitleSourceTrack setObject:[NSNumber numberWithInt:[subtitleSourceArray count]+1] forKey:@"sourceTrackNum"];
[newSubtitleSourceTrack setObject:[NSNumber numberWithInteger:[subtitleSourceArray count]+1] forKey:@"sourceTrackNum"];
/* Subtitle Source track name */
[newSubtitleSourceTrack setObject:displayname forKey:@"sourceTrackName"];
/* Subtitle Source track type (VobSub, Srt, etc.) */
@ -340,7 +339,7 @@
* specified as we always keep one track set to "None" which is ignored
* for setting up tracks, but is used to add tracks.
*/
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
- (NSUInteger)numberOfRowsInTableView:(NSTableView *)aTableView
{
if( fTitle == NULL || ![subtitleArray count])
{
@ -781,7 +780,7 @@
else
{
[aCell selectItemAtIndex:languagesArrayDefIndex]; // English
[[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInt:languagesArrayDefIndex] forKey:@"subtitleTrackSrtLanguageIndex"];
[[subtitleArray objectAtIndex:rowIndex] setObject:[NSNumber numberWithInteger:languagesArrayDefIndex] forKey:@"subtitleTrackSrtLanguageIndex"];
[[subtitleArray objectAtIndex:rowIndex] setObject:[[languagesArray objectAtIndex:languagesArrayDefIndex] objectAtIndex:0] forKey:@"subtitleTrackSrtLanguageLong"];
[[subtitleArray objectAtIndex:rowIndex] setObject:[[languagesArray objectAtIndex:languagesArrayDefIndex] objectAtIndex:1] forKey:@"subtitleTrackSrtLanguageIso3"];
@ -879,8 +878,8 @@
defaultButton:@"OK"
alternateButton:nil
otherButton:nil
informativeTextWithFormat:@"%d subtitle %@ could neither be converted to burn-in nor passed through",
[tracksToDelete count],
informativeTextWithFormat:@"%lu subtitle %@ could neither be converted to burn-in nor passed through",
(unsigned long)[tracksToDelete count],
[tracksToDelete count] > 1 ? @"tracks" : @"track"] runModal];
}
[tracksToDelete release];

View File

@ -243,11 +243,9 @@
{
NSBox * filterBox = nil;
NSTextField * filterField;
if (sender == fDetelecinePopUp)
{
filterBox = fDetelecineBox;
filterField = fDetelecineField;
}
if (sender == fDecombDeinterlaceSlider)
@ -255,30 +253,25 @@
if ([fDecombDeinterlaceSlider floatValue] == 0.0)
{
filterBox = fDecombBox;
filterField = fDecombField;
}
else
{
filterBox = fDeinterlaceBox;
filterField = fDeinterlaceField;
}
}
if (sender == fDecombPopUp)
{
filterBox = fDecombBox;
filterField = fDecombField;
}
if (sender == fDeinterlacePopUp)
{
filterBox = fDeinterlaceBox;
filterField = fDeinterlaceField;
}
if (sender == fDenoisePopUp)
{
filterBox = fDenoiseBox;
filterField = fDenoiseField;
}
NSSize currentSize = [filterBox frame].size;