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: @"\""];
} }
......
This diff is collapsed.
...@@ -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