Commit 2c828226 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: saved various objc selector dispatches when iterating, additionally fixes #5113

parent eab70f5d
...@@ -246,11 +246,11 @@ static int Open( vlc_object_t *p_this ) ...@@ -246,11 +246,11 @@ static int Open( vlc_object_t *p_this )
goto error; goto error;
} }
int ivideo; NSUInteger deviceCount = [myVideoDevices count];
for(ivideo = 0; ivideo < [myVideoDevices count]; ivideo++){ for(NSUInteger ivideo = 0; ivideo < deviceCount; ivideo++){
QTCaptureDevice *qtk_device; QTCaptureDevice *qtk_device;
qtk_device = [myVideoDevices objectAtIndex:ivideo]; qtk_device = [myVideoDevices objectAtIndex:ivideo];
msg_Dbg( p_demux, "qtcapture %d/%lu %s %s", ivideo, [myVideoDevices count], [[qtk_device localizedDisplayName] UTF8String], [[qtk_device uniqueID] UTF8String]); msg_Dbg( p_demux, "qtcapture %d/%lu %s %s", ivideo, deviceCount, [[qtk_device localizedDisplayName] UTF8String], [[qtk_device uniqueID] UTF8String]);
if([[[qtk_device uniqueID]stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtk_currdevice_uid]){ if([[[qtk_device uniqueID]stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtk_currdevice_uid]){
break; break;
} }
...@@ -302,7 +302,8 @@ static int Open( vlc_object_t *p_this ) ...@@ -302,7 +302,8 @@ static int Open( vlc_object_t *p_this )
/* Get the formats */ /* Get the formats */
NSArray *format_array = [p_sys->device formatDescriptions]; NSArray *format_array = [p_sys->device formatDescriptions];
QTFormatDescription* camera_format = NULL; QTFormatDescription* camera_format = NULL;
for( int k = 0; k < [format_array count]; k++ ) NSUInteger formatCount = [format_array count];
for( NSUInteger k = 0; k < formatCount; k++ )
{ {
camera_format = [format_array objectAtIndex: k]; camera_format = [format_array objectAtIndex: k];
......
...@@ -627,8 +627,8 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon, ...@@ -627,8 +627,8 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
memset(cookies, 0, sizeof(IOHIDElementCookie) * NUMBER_OF_APPLE_REMOTE_ACTIONS); memset(cookies, 0, sizeof(IOHIDElementCookie) * NUMBER_OF_APPLE_REMOTE_ACTIONS);
*/ */
allCookies = [[NSMutableArray alloc] init]; allCookies = [[NSMutableArray alloc] init];
unsigned int i; NSUInteger elementCount = [elements count];
for (i=0; i< [elements count]; i++) { for (NSUInteger i=0; i< elementCount; i++) {
element = [elements objectAtIndex:i]; element = [elements objectAtIndex:i];
//Get cookie //Get cookie
...@@ -668,8 +668,8 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon, ...@@ -668,8 +668,8 @@ static void QueueCallbackFunction(void* target, IOReturn result, void* refcon,
if (queue) { if (queue) {
result = (*queue)->create(queue, 0, 12); //depth: maximum number of elements in queue before oldest elements in queue begin to be lost. result = (*queue)->create(queue, 0, 12); //depth: maximum number of elements in queue before oldest elements in queue begin to be lost.
unsigned int i=0; NSUInteger cookieCount = [allCookies count];
for(i=0; i<[allCookies count]; i++) { for(NSUInteger i=0; i<cookieCount; i++) {
IOHIDElementCookie cookie = (IOHIDElementCookie)[[allCookies objectAtIndex:i] intValue]; IOHIDElementCookie cookie = (IOHIDElementCookie)[[allCookies objectAtIndex:i] intValue];
(*queue)->addElement(queue, cookie, 0); (*queue)->addElement(queue, cookie, 0);
} }
......
...@@ -375,7 +375,8 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -375,7 +375,8 @@ static VLCMainMenu *_o_sharedInstance = nil;
if( !p_intf ) return; if( !p_intf ) return;
NSArray *menuitems_array = [the_menu itemArray]; NSArray *menuitems_array = [the_menu itemArray];
for( int i=0; i<[menuitems_array count]; i++ ) NSUInteger menuItemCount = [menuitems_array count];
for( NSUInteger i=0; i < menuItemCount; i++ )
{ {
NSMenuItem *one_item = [menuitems_array objectAtIndex: i]; NSMenuItem *one_item = [menuitems_array objectAtIndex: i];
if( [one_item hasSubmenu] ) if( [one_item hasSubmenu] )
......
...@@ -106,7 +106,8 @@ static VLAboutBox *_o_sharedInstance = nil; ...@@ -106,7 +106,8 @@ static VLAboutBox *_o_sharedInstance = nil;
[o_name_version_field setStringValue: [NSString stringWithFormat:@"Version %s (%s)", VERSION_MESSAGE, PLATFORM]]; [o_name_version_field setStringValue: [NSString stringWithFormat:@"Version %s (%s)", VERSION_MESSAGE, PLATFORM]];
NSMutableArray *tmpArray = [NSMutableArray arrayWithArray: [[NSString stringWithUTF8String: psz_authors]componentsSeparatedByString:@"\n\n"]]; NSMutableArray *tmpArray = [NSMutableArray arrayWithArray: [[NSString stringWithUTF8String: psz_authors]componentsSeparatedByString:@"\n\n"]];
for( int i = 0; i < [tmpArray count]; i++ ) NSUInteger count = [tmpArray count];
for( NSUInteger i = 0; i < count; i++ )
{ {
[tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByReplacingOccurrencesOfString:@"\n" withString:@", "]]; [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByReplacingOccurrencesOfString:@"\n" withString:@", "]];
[tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByReplacingOccurrencesOfString:@", -" withString:@"\n-" options:0 range:NSRangeFromString(@"0 30")]]; [tmpArray replaceObjectAtIndex:i withObject:[[tmpArray objectAtIndex:i]stringByReplacingOccurrencesOfString:@", -" withString:@"\n-" options:0 range:NSRangeFromString(@"0 30")]];
......
...@@ -83,9 +83,9 @@ static NSMutableArray *blackoutWindows = NULL; ...@@ -83,9 +83,9 @@ static NSMutableArray *blackoutWindows = NULL;
+ (NSScreen *)screenWithDisplayID: (CGDirectDisplayID)displayID + (NSScreen *)screenWithDisplayID: (CGDirectDisplayID)displayID
{ {
int i; NSUInteger count = [[NSScreen screens] count];
for( i = 0; i < [[NSScreen screens] count]; i++ ) for( NSUInteger i = 0; i < count; i++ )
{ {
NSScreen *screen = [[NSScreen screens] objectAtIndex: i]; NSScreen *screen = [[NSScreen screens] objectAtIndex: i];
if([screen displayID] == displayID) if([screen displayID] == displayID)
...@@ -111,13 +111,12 @@ static NSMutableArray *blackoutWindows = NULL; ...@@ -111,13 +111,12 @@ static NSMutableArray *blackoutWindows = NULL;
- (void)blackoutOtherScreens - (void)blackoutOtherScreens
{ {
unsigned int i;
/* Free our previous blackout window (follow blackoutWindow alloc strategy) */ /* Free our previous blackout window (follow blackoutWindow alloc strategy) */
[blackoutWindows makeObjectsPerformSelector:@selector(close)]; [blackoutWindows makeObjectsPerformSelector:@selector(close)];
[blackoutWindows removeAllObjects]; [blackoutWindows removeAllObjects];
for(i = 0; i < [[NSScreen screens] count]; i++) NSUInteger screenCount = [[NSScreen screens] count];
for(NSUInteger i = 0; i < screenCount; i++)
{ {
NSScreen *screen = [[NSScreen screens] objectAtIndex: i]; NSScreen *screen = [[NSScreen screens] objectAtIndex: i];
VLCWindow *blackoutWindow; VLCWindow *blackoutWindow;
...@@ -151,9 +150,9 @@ static NSMutableArray *blackoutWindows = NULL; ...@@ -151,9 +150,9 @@ static NSMutableArray *blackoutWindows = NULL;
+ (void)unblackoutScreens + (void)unblackoutScreens
{ {
unsigned int i; NSUInteger blackoutWindowCount = [blackoutWindows count];
for(i = 0; i < [blackoutWindows count]; i++) for(NSUInteger i = 0; i < blackoutWindowCount; i++)
{ {
VLCWindow *blackoutWindow = [blackoutWindows objectAtIndex: i]; VLCWindow *blackoutWindow = [blackoutWindows objectAtIndex: i];
[blackoutWindow closeAndAnimate: YES]; [blackoutWindow closeAndAnimate: YES];
...@@ -398,12 +397,11 @@ static NSMutableArray *blackoutWindows = NULL; ...@@ -398,12 +397,11 @@ static NSMutableArray *blackoutWindows = NULL;
{ {
if ([o_desired_type isEqualToString:NSFilenamesPboardType]) if ([o_desired_type isEqualToString:NSFilenamesPboardType])
{ {
int i;
NSArray *o_array = [NSArray array]; NSArray *o_array = [NSArray array];
NSArray *o_values = [[o_paste propertyListForType: NSFilenamesPboardType] NSArray *o_values = [[o_paste propertyListForType: NSFilenamesPboardType] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; NSUInteger count = [o_values count];
for( i = 0; i < (int)[o_values count]; i++) for( NSUInteger i = 0; i < count; i++)
{ {
NSDictionary *o_dic; NSDictionary *o_dic;
char *psz_uri = make_URI([[o_values objectAtIndex:i] UTF8String], NULL); char *psz_uri = make_URI([[o_values objectAtIndex:i] UTF8String], NULL);
...@@ -483,12 +481,11 @@ static NSMutableArray *blackoutWindows = NULL; ...@@ -483,12 +481,11 @@ static NSMutableArray *blackoutWindows = NULL;
{ {
if ([o_desired_type isEqualToString:NSFilenamesPboardType]) if ([o_desired_type isEqualToString:NSFilenamesPboardType])
{ {
int i;
NSArray *o_array = [NSArray array]; NSArray *o_array = [NSArray array];
NSArray *o_values = [[o_paste propertyListForType: NSFilenamesPboardType] NSArray *o_values = [[o_paste propertyListForType: NSFilenamesPboardType] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; NSUInteger count = [o_values count];
for( i = 0; i < (int)[o_values count]; i++) for( NSUInteger i = 0; i < count; i++)
{ {
NSDictionary *o_dic; NSDictionary *o_dic;
char *psz_uri = make_URI([[o_values objectAtIndex:i] UTF8String], NULL); char *psz_uri = make_URI([[o_values objectAtIndex:i] UTF8String], NULL);
......
...@@ -211,7 +211,8 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -211,7 +211,8 @@ static VLCOpen *_o_sharedMainInstance = nil;
qtk_currdevice_uid = [[[QTCaptureDevice defaultInputDeviceWithMediaType: QTMediaTypeVideo] uniqueID] qtk_currdevice_uid = [[[QTCaptureDevice defaultInputDeviceWithMediaType: QTMediaTypeVideo] uniqueID]
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
} }
for(int ivideo = 0; ivideo < [qtkvideoDevices count]; ivideo++){ NSUInteger deviceCount = [qtkvideoDevices count];
for(int ivideo = 0; ivideo < deviceCount; ivideo++){
QTCaptureDevice *qtk_device; QTCaptureDevice *qtk_device;
qtk_device = [qtkvideoDevices objectAtIndex:ivideo]; qtk_device = [qtkvideoDevices objectAtIndex:ivideo];
[o_qtk_device_pop addItemWithTitle: [qtk_device localizedDisplayName]]; [o_qtk_device_pop addItemWithTitle: [qtk_device localizedDisplayName]];
...@@ -368,7 +369,6 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -368,7 +369,6 @@ static VLCOpen *_o_sharedMainInstance = nil;
{ {
NSMutableDictionary *o_dic; NSMutableDictionary *o_dic;
NSMutableArray *o_options = [NSMutableArray array]; NSMutableArray *o_options = [NSMutableArray array];
unsigned int i;
o_dic = [NSMutableDictionary dictionaryWithObject: [self MRL] forKey: @"ITEM_URL"]; o_dic = [NSMutableDictionary dictionaryWithObject: [self MRL] forKey: @"ITEM_URL"];
if( [o_file_sub_ckbox state] == NSOnState ) if( [o_file_sub_ckbox state] == NSOnState )
...@@ -400,10 +400,10 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -400,10 +400,10 @@ static VLCOpen *_o_sharedMainInstance = nil;
} }
if( [o_output_ckbox state] == NSOnState ) if( [o_output_ckbox state] == NSOnState )
{ {
for (i = 0 ; i < [[o_sout_options mrl] count] ; i++) NSUInteger count = [[o_sout_options mrl] count];
for (NSUInteger i = 0 ; i < count ; i++)
{ {
[o_options addObject: [NSString stringWithString: [o_options addObject: [NSString stringWithString: [[(VLCOutput *)o_sout_options mrl] objectAtIndex: i]]];
[[(VLCOutput *)o_sout_options mrl] objectAtIndex: i]]];
} }
} }
if( [o_file_slave_ckbox state] && o_file_slave_path ) if( [o_file_slave_ckbox state] && o_file_slave_path )
...@@ -752,7 +752,8 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -752,7 +752,8 @@ static VLCOpen *_o_sharedMainInstance = nil;
{ {
NSArray * topLevelItems; NSArray * topLevelItems;
topLevelItems = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath: mountPath error: NULL]; topLevelItems = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath: mountPath error: NULL];
for (int i = 0; i < [topLevelItems count]; i++) { NSUInteger itemCount = [topLevelItems count];
for (int i = 0; i < itemCount; i++) {
if([[topLevelItems objectAtIndex:i] rangeOfString:@"SVCD"].location != NSNotFound) { if([[topLevelItems objectAtIndex:i] rangeOfString:@"SVCD"].location != NSNotFound) {
returnValue = kVLCMediaSVCD; returnValue = kVLCMediaSVCD;
break; break;
...@@ -835,7 +836,8 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -835,7 +836,8 @@ static VLCOpen *_o_sharedMainInstance = nil;
if ([o_specialMediaFolders count] > 0) if ([o_specialMediaFolders count] > 0)
[o_opticalDevices addObjectsFromArray: o_specialMediaFolders]; [o_opticalDevices addObjectsFromArray: o_specialMediaFolders];
if ([o_opticalDevices count] > 0) { if ([o_opticalDevices count] > 0) {
for (int i = 0; i < [o_opticalDevices count] ; i++) NSUInteger deviceCount = [o_opticalDevices count];
for (NSUInteger i = 0; i < deviceCount ; i++)
[o_disc_selector_pop addItemWithTitle: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: i]]]; [o_disc_selector_pop addItemWithTitle: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: i]]];
if ([o_disc_selector_pop numberOfItems] <= 1) if ([o_disc_selector_pop numberOfItems] <= 1)
......
...@@ -416,27 +416,21 @@ ...@@ -416,27 +416,21 @@
/* split up the hostname and the following path to paste the /* split up the hostname and the following path to paste the
* port correctly. Not need, if there isn't any path following the * port correctly. Not need, if there isn't any path following the
* hostname. */ * hostname. */
NSArray * o_urlItems = [[o_stream_address stringValue] \ NSArray * o_urlItems = [[o_stream_address stringValue] componentsSeparatedByString: @"/"];
componentsSeparatedByString: @"/"];
NSMutableString * o_finalStreamAddress; NSMutableString * o_finalStreamAddress;
o_finalStreamAddress = [[NSMutableString alloc] init]; o_finalStreamAddress = [[NSMutableString alloc] init];
if ([o_urlItems count] == 1) if ([o_urlItems count] == 1)
{ {
[o_finalStreamAddress appendFormat: @"\"%@:%@\"", \ [o_finalStreamAddress appendFormat: @"\"%@:%@\"", [o_stream_address stringValue],[o_stream_port stringValue]];
[o_stream_address stringValue],[o_stream_port stringValue]];
} }
else else
{ {
[o_finalStreamAddress appendFormat: @"\"%@:%@", [o_urlItems \ [o_finalStreamAddress appendFormat: @"\"%@:%@", [o_urlItems objectAtIndex: 0], [o_stream_port stringValue]];
objectAtIndex: 0], [o_stream_port stringValue]]; NSUInteger itemCount = [o_urlItems count];
unsigned int x; for (NSUInteger x = 0; x < itemCount; x++)
x = 1;
while (x != [o_urlItems count])
{ {
[o_finalStreamAddress appendFormat: @"/%@", [o_urlItems \ [o_finalStreamAddress appendFormat: @"/%@", [o_urlItems objectAtIndex: x]];
objectAtIndex: x]];
x = (x + 1);
} }
[o_finalStreamAddress appendString: @"\""]; [o_finalStreamAddress appendString: @"\""];
} }
......
...@@ -502,7 +502,8 @@ ...@@ -502,7 +502,8 @@
- (void)playlistUpdated - (void)playlistUpdated
{ {
/* Clear indications of any existing column sorting */ /* Clear indications of any existing column sorting */
for( unsigned int i = 0 ; i < [[o_outline_view tableColumns] count] ; i++ ) NSUInteger count = [[o_outline_view tableColumns] count];
for( NSUInteger i = 0 ; i < count ; i++ )
{ {
[o_outline_view setIndicatorImage:nil inTableColumn: [o_outline_view setIndicatorImage:nil inTableColumn:
[[o_outline_view tableColumns] objectAtIndex:i]]; [[o_outline_view tableColumns] objectAtIndex:i]];
...@@ -561,9 +562,6 @@ ...@@ -561,9 +562,6 @@
- (void)updateRowSelection - (void)updateRowSelection
{ {
int i_row;
unsigned int j;
// FIXME: unsafe // FIXME: unsafe
playlist_t *p_playlist = pl_Get( VLCIntf ); playlist_t *p_playlist = pl_Get( VLCIntf );
playlist_item_t *p_item, *p_temp_item; playlist_item_t *p_item, *p_temp_item;
...@@ -585,7 +583,8 @@ ...@@ -585,7 +583,8 @@
} }
PL_UNLOCK; PL_UNLOCK;
for( j = 0; j < [o_array count] - 1; j++ ) NSUInteger count = [o_array count];
for( NSUInteger j = 0; j < count - 1; j++ )
{ {
id o_item; id o_item;
if( ( o_item = [o_outline_dict objectForKey: if( ( o_item = [o_outline_dict objectForKey:
...@@ -663,10 +662,11 @@ ...@@ -663,10 +662,11 @@
already selected node */ already selected node */
- (void)removeItemsFrom:(id)o_items ifChildrenOf:(id)o_nodes - (void)removeItemsFrom:(id)o_items ifChildrenOf:(id)o_nodes
{ {
unsigned int i, j; NSUInteger itemCount = [o_items count];
for( i = 0 ; i < [o_items count] ; i++ ) NSUInteger nodeCount = [o_nodes count];
for( NSUInteger i = 0 ; i < itemCount ; i++ )
{ {
for ( j = 0 ; j < [o_nodes count] ; j++ ) for ( NSUInteger j = 0 ; j < nodeCount ; j++ )
{ {
if( o_items == o_nodes) if( o_items == o_nodes)
{ {
...@@ -990,7 +990,6 @@ ...@@ -990,7 +990,6 @@
playlist_t * p_playlist = pl_Get( p_intf ); playlist_t * p_playlist = pl_Get( p_intf );
input_item_t *p_input; input_item_t *p_input;
int i;
BOOL b_rem = FALSE, b_dir = FALSE; BOOL b_rem = FALSE, b_dir = FALSE;
NSString *o_uri, *o_name; NSString *o_uri, *o_name;
NSArray *o_options; NSArray *o_options;
...@@ -1004,12 +1003,12 @@ ...@@ -1004,12 +1003,12 @@
/* Find the name for a disc entry (i know, can you believe the trouble?) */ /* Find the name for a disc entry (i know, can you believe the trouble?) */
if( ( !o_name || [o_name isEqualToString:@""] ) && [o_uri rangeOfString: @"/dev/"].location != NSNotFound ) if( ( !o_name || [o_name isEqualToString:@""] ) && [o_uri rangeOfString: @"/dev/"].location != NSNotFound )
{ {
int i_count, i_index; int i_count;
struct statfs *mounts = NULL; struct statfs *mounts = NULL;
i_count = getmntinfo (&mounts, MNT_NOWAIT); i_count = getmntinfo (&mounts, MNT_NOWAIT);
/* getmntinfo returns a pointer to static data. Do not free. */ /* getmntinfo returns a pointer to static data. Do not free. */
for( i_index = 0 ; i_index < i_count; i_index++ ) for( int i_index = 0 ; i_index < i_count; i_index++ )
{ {
NSMutableString *o_temp, *o_temp2; NSMutableString *o_temp, *o_temp2;
o_temp = [NSMutableString stringWithString: o_uri]; o_temp = [NSMutableString stringWithString: o_uri];
...@@ -1051,7 +1050,8 @@ ...@@ -1051,7 +1050,8 @@
if( o_options ) if( o_options )
{ {
for( i = 0; i < (int)[o_options count]; i++ ) NSUInteger count = [o_options count];
for( NSUInteger i = 0; i < count; i++ )
{ {
input_item_AddOption( p_input, [[o_options objectAtIndex:i] UTF8String], input_item_AddOption( p_input, [[o_options objectAtIndex:i] UTF8String],
VLC_INPUT_OPTION_TRUSTED ); VLC_INPUT_OPTION_TRUSTED );
...@@ -1070,11 +1070,11 @@ ...@@ -1070,11 +1070,11 @@
- (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue - (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue
{ {
int i_item;
playlist_t * p_playlist = pl_Get( VLCIntf ); playlist_t * p_playlist = pl_Get( VLCIntf );
NSUInteger count = [o_array count];
PL_LOCK; PL_LOCK;
for( i_item = 0; i_item < (int)[o_array count]; i_item++ ) for( NSUInteger i_item = 0; i_item < count; i_item++ )
{ {
input_item_t *p_input; input_item_t *p_input;
NSDictionary *o_one_item; NSDictionary *o_one_item;
...@@ -1090,11 +1090,10 @@ ...@@ -1090,11 +1090,10 @@
/* Add the item */ /* Add the item */
/* FIXME: playlist_AddInput() can fail */ /* FIXME: playlist_AddInput() can fail */
playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT, playlist_AddInput( p_playlist, p_input, PLAYLIST_INSERT, i_position == -1 ? PLAYLIST_END : i_position + i_item, true,
i_position == -1 ? PLAYLIST_END : i_position + i_item, true,
pl_Locked ); pl_Locked );
if( i_item == 0 && !b_enqueue ) /* if( i_item == 0 && !b_enqueue )
{ {
playlist_item_t *p_item = NULL; playlist_item_t *p_item = NULL;
playlist_item_t *p_node = NULL; playlist_item_t *p_node = NULL;
...@@ -1113,20 +1112,22 @@ ...@@ -1113,20 +1112,22 @@
} }
playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Locked, p_node, p_item ); playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, pl_Locked, p_node, p_item );
} }
} }*/
vlc_gc_decref( p_input ); vlc_gc_decref( p_input );
} }
PL_UNLOCK; PL_UNLOCK;
[o_outline_view selectRowIndexes:[NSIndexSet indexSetWithIndex:i_position] byExtendingSelection:YES];
[self playItem:nil];
[self playlistUpdated]; [self playlistUpdated];
} }
- (void)appendNodeArray:(NSArray*)o_array inNode:(playlist_item_t *)p_node atPos:(int)i_position enqueue:(BOOL)b_enqueue - (void)appendNodeArray:(NSArray*)o_array inNode:(playlist_item_t *)p_node atPos:(int)i_position enqueue:(BOOL)b_enqueue
{ {
int i_item;
playlist_t * p_playlist = pl_Get( VLCIntf ); playlist_t * p_playlist = pl_Get( VLCIntf );
NSUInteger count = [o_array count];
for( i_item = 0; i_item < (int)[o_array count]; i_item++ ) for( NSUInteger i_item = 0; i_item < count; i_item++ )
{ {
input_item_t *p_input; input_item_t *p_input;
NSDictionary *o_one_item; NSDictionary *o_one_item;
...@@ -1162,16 +1163,15 @@ ...@@ -1162,16 +1163,15 @@
{ {
playlist_t *p_playlist = pl_Get( VLCIntf ); playlist_t *p_playlist = pl_Get( VLCIntf );
playlist_item_t *p_selected_item; playlist_item_t *p_selected_item;
int i_current, i_selected_row; int i_selected_row;
i_selected_row = [o_outline_view selectedRow]; i_selected_row = [o_outline_view selectedRow];
if (i_selected_row < 0) if (i_selected_row < 0)
i_selected_row = 0; i_selected_row = 0;
p_selected_item = (playlist_item_t *)[[o_outline_view itemAtRow: p_selected_item = (playlist_item_t *)[[o_outline_view itemAtRow: i_selected_row] pointerValue];
i_selected_row] pointerValue];
for( i_current = 0; i_current < p_item->i_children ; i_current++ ) for( NSUInteger i_current = 0; i_current < p_item->i_children ; i_current++ )
{ {
char *psz_temp; char *psz_temp;
NSString *o_current_name, *o_current_author; NSString *o_current_name, *o_current_author;
...@@ -1226,7 +1226,6 @@ ...@@ -1226,7 +1226,6 @@
playlist_t * p_playlist = pl_Get( VLCIntf ); playlist_t * p_playlist = pl_Get( VLCIntf );
id o_result; id o_result;
unsigned int i;
int i_row = -1; int i_row = -1;
b_selected_item_met = NO; b_selected_item_met = NO;
...@@ -1242,13 +1241,13 @@ ...@@ -1242,13 +1241,13 @@
if( o_result != NULL ) if( o_result != NULL )
{ {
int i_start; int i_start;
if( [[o_result objectAtIndex: 0] pointerValue] == if( [[o_result objectAtIndex: 0] pointerValue] == p_playlist->p_local_category )
p_playlist->p_local_category )
i_start = 1; i_start = 1;
else else
i_start = 0; i_start = 0;
NSUInteger count = [o_result count];
for( i = i_start ; i < [o_result count] - 1 ; i++ ) for( NSUInteger i = i_start ; i < count - 1 ; i++ )
{ {
[o_outline_view expandItem: [o_outline_dict objectForKey: [o_outline_view expandItem: [o_outline_dict objectForKey:
[NSString stringWithFormat: @"%p", [NSString stringWithFormat: @"%p",
...@@ -1256,7 +1255,7 @@ ...@@ -1256,7 +1255,7 @@
} }
i_row = [o_outline_view rowForItem: [o_outline_dict objectForKey: i_row = [o_outline_view rowForItem: [o_outline_dict objectForKey:
[NSString stringWithFormat: @"%p", [NSString stringWithFormat: @"%p",
[[o_result objectAtIndex: [o_result count] - 1 ] [[o_result objectAtIndex: count - 1 ]
pointerValue]]]]; pointerValue]]]];
} }
if( i_row > -1 ) if( i_row > -1 )
...@@ -1426,7 +1425,6 @@ ...@@ -1426,7 +1425,6 @@
/* Required for drag & drop and reordering */ /* Required for drag & drop and reordering */
- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
{ {
unsigned int i;
playlist_t *p_playlist = pl_Get( VLCIntf ); playlist_t *p_playlist = pl_Get( VLCIntf );
/* First remove the items that were moved during the last drag & drop /* First remove the items that were moved during the last drag & drop
...@@ -1434,7 +1432,9 @@ ...@@ -1434,7 +1432,9 @@
[o_items_array removeAllObjects]; [o_items_array removeAllObjects];
[o_nodes_array removeAllObjects]; [o_nodes_array removeAllObjects];
for( i = 0 ; i < [items count] ; i++ ) NSUInteger itemCount = [items count];
for( NSUInteger i = 0 ; i < itemCount ; i++ )
{ {
id o_item = [items objectAtIndex: i]; id o_item = [items objectAtIndex: i];
...@@ -1504,8 +1504,8 @@ ...@@ -1504,8 +1504,8 @@
/* Drop from the Playlist */ /* Drop from the Playlist */
if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] ) if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
{ {
unsigned int i; NSUInteger count = [o_nodes_array count];
for( i = 0 ; i < [o_nodes_array count] ; i++ ) for( NSUInteger i = 0 ; i < count ; i++ )
{ {
/* We refuse to Drop in a child of an item we are moving */ /* We refuse to Drop in a child of an item we are moving */
if( [self isItem: [item pointerValue] inNode: if( [self isItem: [item pointerValue] inNode:
...@@ -1535,7 +1535,6 @@ ...@@ -1535,7 +1535,6 @@
if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] ) if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
{ {
int i_row, i_removed_from_node = 0; int i_row, i_removed_from_node = 0;
unsigned int i;
playlist_item_t *p_new_parent, *p_item = NULL; playlist_item_t *p_new_parent, *p_item = NULL;
NSArray *o_all_items = [o_nodes_array arrayByAddingObjectsFromArray: NSArray *o_all_items = [o_nodes_array arrayByAddingObjectsFromArray:
o_items_array]; o_items_array];
...@@ -1552,7 +1551,8 @@ ...@@ -1552,7 +1551,8 @@
return NO; return NO;
} }
for( i = 0; i < [o_all_items count]; i++ ) NSUInteger count = [o_all_items count];
for( NSUInteger i = 0; i < count; i++ )
{ {
playlist_item_t *p_old_parent = NULL; playlist_item_t *p_old_parent = NULL;
int i_old_index = 0; int i_old_index = 0;
...@@ -1564,8 +1564,7 @@ ...@@ -1564,8 +1564,7 @@
/* We may need the old index later */ /* We may need the old index later */
if( p_new_parent == p_old_parent ) if( p_new_parent == p_old_parent )
{ {
int j; for( NSInteger j = 0; j < p_old_parent->i_children; j++ )
for( j = 0; j < p_old_parent->i_children; j++ )
{ {
if( p_old_parent->pp_children[j] == p_item ) if( p_old_parent->pp_children[j] == p_item )
{ {
...@@ -1588,8 +1587,7 @@ ...@@ -1588,8 +1587,7 @@
account that one item will be deleted */ account that one item will be deleted */
else else
{ {
if ((p_new_parent == p_old_parent && if ((p_new_parent == p_old_parent && i_old_index < index + (int)i) )
i_old_index < index + (int)i) )
{ {
i_removed_from_node++; i_removed_from_node++;
} }
...@@ -1617,16 +1615,14 @@ ...@@ -1617,16 +1615,14 @@
else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] ) else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
{ {
int i;
playlist_item_t *p_node = [item pointerValue]; playlist_item_t *p_node = [item pointerValue];
NSArray *o_array = [NSArray array]; NSArray *o_values = [[o_pasteboard propertyListForType: NSFilenamesPboardType]
NSArray *o_values = [[o_pasteboard propertyListForType: sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)];
NSFilenamesPboardType] NSUInteger count = [o_values count];
sortedArrayUsingSelector: NSMutableArray *o_array = [NSMutableArray arrayWithCapacity:count];
@selector(caseInsensitiveCompare:)];
for( i = 0; i < (int)[o_values count]; i++) for( NSUInteger i = 0; i < count; i++)
{ {
NSDictionary *o_dic; NSDictionary *o_dic;
char *psz_uri = make_URI([[o_values objectAtIndex:i] UTF8String], NULL); char *psz_uri = make_URI([[o_values objectAtIndex:i] UTF8String], NULL);
...@@ -1637,7 +1633,7 @@ ...@@ -1637,7 +1633,7 @@
free( psz_uri ); free( psz_uri );
o_array = [o_array arrayByAddingObject: o_dic]; [o_array addObject: o_dic];
} }
if ( item == nil ) if ( item == nil )
...@@ -1647,8 +1643,7 @@ ...@@ -1647,8 +1643,7 @@
else else
{ {
assert( p_node->i_children != -1 ); assert( p_node->i_children != -1 );
[self appendNodeArray:o_array inNode: p_node [self appendNodeArray:o_array inNode: p_node atPos:index enqueue:YES];
atPos:index enqueue:YES];
} }
return YES; return YES;
} }
......
...@@ -295,7 +295,8 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -295,7 +295,8 @@ static VLCPrefs *_o_sharedMainInstance = nil;
- (VLCTreeCategoryItem *)itemRepresentingCategory:(int)category - (VLCTreeCategoryItem *)itemRepresentingCategory:(int)category
{ {
for( int i = 0; i < [[self children] count]; i++ ) NSUInteger childrenCount = [[self children] count];
for( int i = 0; i < childrenCount; i++ )
{ {
VLCTreeCategoryItem * categoryItem = [[self children] objectAtIndex:i]; VLCTreeCategoryItem * categoryItem = [[self children] objectAtIndex:i];
if( [categoryItem category] == category ) if( [categoryItem category] == category )
...@@ -433,7 +434,8 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -433,7 +434,8 @@ static VLCPrefs *_o_sharedMainInstance = nil;
- (VLCTreeSubCategoryItem *)itemRepresentingSubCategory:(int)subCategory - (VLCTreeSubCategoryItem *)itemRepresentingSubCategory:(int)subCategory
{ {
assert( [self isKindOfClass:[VLCTreeCategoryItem class]] ); assert( [self isKindOfClass:[VLCTreeCategoryItem class]] );
for( int i = 0; i < [[self children] count]; i++ ) NSUInteger childrenCount = [[self children] count];
for( NSUInteger i = 0; i < childrenCount; i++ )
{ {
VLCTreeSubCategoryItem * subCategoryItem = [[self children] objectAtIndex:i]; VLCTreeSubCategoryItem * subCategoryItem = [[self children] objectAtIndex:i];
if( [subCategoryItem subCategory] == subCategory ) if( [subCategoryItem subCategory] == subCategory )
...@@ -584,8 +586,8 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -584,8 +586,8 @@ static VLCPrefs *_o_sharedMainInstance = nil;
{ {
_subviews = [[NSMutableArray alloc] initWithCapacity:10]; _subviews = [[NSMutableArray alloc] initWithCapacity:10];
long i; NSUInteger count = [[self options] count];
for( i = 0; i < [[self options] count]; i++) for( NSUInteger i = 0; i < count; i++)
{ {
VLCTreeLeafItem * item = [[self options] objectAtIndex:i]; VLCTreeLeafItem * item = [[self options] objectAtIndex:i];
...@@ -638,24 +640,29 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -638,24 +640,29 @@ static VLCPrefs *_o_sharedMainInstance = nil;
- (void)applyChanges - (void)applyChanges
{ {
unsigned int i; NSUInteger i;
for( i = 0 ; i < [_subviews count] ; i++ ) NSUInteger count = [_subviews count];
for( i = 0 ; i < count ; i++ )
[[_subviews objectAtIndex:i] applyChanges]; [[_subviews objectAtIndex:i] applyChanges];
for( i = 0 ; i < [_children count] ; i++ ) count = [_children count];
for( i = 0 ; i < count ; i++ )
[[_children objectAtIndex:i] applyChanges]; [[_children objectAtIndex:i] applyChanges];
} }
- (void)resetView - (void)resetView
{ {
unsigned int i; NSUInteger i;
for( i = 0 ; i < [_subviews count] ; i++ ) NSUInteger count = [_subviews count];
for( i = 0 ; i < count ; i++ )
[[_subviews objectAtIndex:i] resetValues]; [[_subviews objectAtIndex:i] resetValues];
for( i = 0 ; i < [_options count] ; i++ ) count = [_options count];
for( i = 0 ; i < count ; i++ )
[[_options objectAtIndex:i] resetView]; [[_options objectAtIndex:i] resetView];
for( i = 0 ; i < [_children count] ; i++ ) count = [_children count];
for( i = 0 ; i < count ; i++ )
[[_children objectAtIndex:i] resetView]; [[_children objectAtIndex:i] resetView];
} }
......
...@@ -2308,8 +2308,8 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ ...@@ -2308,8 +2308,8 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \
- (IBAction)tableChanged:(id)sender - (IBAction)tableChanged:(id)sender
{ {
NSString *o_newstring = @""; NSString *o_newstring = @"";
unsigned int i; NSUInteger count = [o_modulearray count];
for( i = 0 ; i < [o_modulearray count] ; i++ ) for( NSUInteger i = 0 ; i < count ; i++ )
if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2] if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2]
boolValue] != NO ) boolValue] != NO )
{ {
......
...@@ -916,7 +916,8 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch ...@@ -916,7 +916,8 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
********************/ ********************/
if( b_hotkeyChanged ) if( b_hotkeyChanged )
{ {
for( NSUInteger i = 0; i < [o_hotkeySettings count]; i++ ) NSUInteger hotKeyCount = [o_hotkeySettings count];
for( NSUInteger i = 0; i < hotKeyCount; i++ )
config_PutPsz( p_intf, [[o_hotkeyNames objectAtIndex:i] UTF8String], [[o_hotkeySettings objectAtIndex:i]UTF8String] ); config_PutPsz( p_intf, [[o_hotkeyNames objectAtIndex:i] UTF8String], [[o_hotkeySettings objectAtIndex:i]UTF8String] );
b_hotkeyChanged = NO; b_hotkeyChanged = NO;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment