* initmethods returning nil. checks moved outside init.
* leaking module_config_get. Keep better track of those.
* spurious strdup
* leaked hotkeys NSMutableArray when resetting the preferences.
(cherry picked from commit
27d841889c9116d46be643fa482f9ca562d233f3)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
NSMutableArray *_children;
NSMutableArray *_options;
NSMutableArray *_subviews;
NSMutableArray *_children;
NSMutableArray *_options;
NSMutableArray *_subviews;
- module_config_t * _configItem;
-- (id)initWithConfigItem:(module_config_t *)configItem;
-- (id)initWithName:(NSString*)name andConfigItem:(module_config_t *)configItem;
+- (id)initWithName:(NSString*)name;
- (int)numberOfChildren;
- (VLCTreeItem *)childAtIndex:(int)i_index;
- (int)numberOfChildren;
- (VLCTreeItem *)childAtIndex:(int)i_index;
-- (module_config_t *)configItem;
-
- (NSString *)name;
- (NSMutableArray *)children;
- (NSMutableArray *)options;
- (NSString *)name;
- (NSMutableArray *)children;
- (NSMutableArray *)options;
/* Plugin daughters */
@interface VLCTreePluginItem : VLCTreeItem
{
/* Plugin daughters */
@interface VLCTreePluginItem : VLCTreeItem
{
+ module_config_t * _configItems;
+ unsigned int _configSize;
}
+ (VLCTreePluginItem *)pluginTreeItemWithPlugin:(module_t *)plugin;
- (id)initWithPlugin:(module_t *)plugin;
}
+ (VLCTreePluginItem *)pluginTreeItemWithPlugin:(module_t *)plugin;
- (id)initWithPlugin:(module_t *)plugin;
+
+- (module_config_t *)configItems;
+- (unsigned int)configSize;
}
+ (VLCTreeCategoryItem *)categoryTreeItemWithCategory:(int)category;
- (id)initWithCategory:(int)category;
}
+ (VLCTreeCategoryItem *)categoryTreeItemWithCategory:(int)category;
- (id)initWithCategory:(int)category;
- (int)category;
- (VLCTreeSubCategoryItem *)itemRepresentingSubCategory:(int)category;
@end
/* individual options. */
@interface VLCTreeLeafItem : VLCTreeItem
- (int)category;
- (VLCTreeSubCategoryItem *)itemRepresentingSubCategory:(int)category;
@end
/* individual options. */
@interface VLCTreeLeafItem : VLCTreeItem
+{
+ module_config_t * _configItem;
+}
+- (id)initWithConfigItem:(module_config_t *)configItem;
+
+- (module_config_t *)configItem;
-@interface VLCTreeMainItem : VLCTreeItem
+@interface VLCTreeMainItem : VLCTreePluginItem
- module_config_t * _configItems;
}
- (VLCTreeCategoryItem *)itemRepresentingCategory:(int)category;
@end
}
- (VLCTreeCategoryItem *)itemRepresentingCategory:(int)category;
@end
-- (void)dealloc
-{
- module_config_free( _configItems );
- [super dealloc];
-}
-
- (bool)isSubCategoryGeneral:(int)category
{
if(category == SUBCAT_VIDEO_GENERAL ||
- (bool)isSubCategoryGeneral:(int)category
{
if(category == SUBCAT_VIDEO_GENERAL ||
/* Add the capabilities */
for( i = 0; i < count; i++ )
{
/* Add the capabilities */
for( i = 0; i < count; i++ )
{
- module_t * p_module = modules[i];
-
- /* Exclude empty plugins (submodules don't have config */
- /* options, they are stored in the parent module) */
- unsigned int confsize;
- _configItems = module_config_get( p_module, &confsize );
-
VLCTreeCategoryItem * categoryItem = nil;
VLCTreeSubCategoryItem * subCategoryItem = nil;
VLCTreePluginItem * pluginItem = nil;
VLCTreeCategoryItem * categoryItem = nil;
VLCTreeSubCategoryItem * subCategoryItem = nil;
VLCTreePluginItem * pluginItem = nil;
+ module_config_t *p_configs = NULL;
+ unsigned int confsize;
+
+ module_t * p_module = modules[i];
+
+ /* Exclude empty plugins (submodules don't have config */
+ /* options, they are stored in the parent module) */
+ if( module_is_main( p_module) )
+ {
+ pluginItem = self;
+ _configItems = module_config_get( p_module, &confsize );
+ _configSize = confsize;
+ } else {
+ pluginItem = [VLCTreePluginItem pluginTreeItemWithPlugin: p_module];
+ confsize = [pluginItem configSize];
+ }
+ p_configs = [pluginItem configItems];
unsigned int j;
for( j = 0; j < confsize; j++ )
{
unsigned int j;
for( j = 0; j < confsize; j++ )
{
- int configType = _configItems[j].i_type;
+ int configType = p_configs[j].i_type;
if( configType == CONFIG_CATEGORY )
{
if( configType == CONFIG_CATEGORY )
{
- categoryItem = [self itemRepresentingCategory:_configItems[j].value.i];
+ categoryItem = [self itemRepresentingCategory:p_configs[j].value.i];
- categoryItem = [VLCTreeCategoryItem categoryTreeItemWithCategory:_configItems[j].value.i];
+ categoryItem = [VLCTreeCategoryItem categoryTreeItemWithCategory:p_configs[j].value.i];
if(categoryItem) [[self children] addObject:categoryItem];
}
}
else if( configType == CONFIG_SUBCATEGORY )
{
if(categoryItem) [[self children] addObject:categoryItem];
}
}
else if( configType == CONFIG_SUBCATEGORY )
{
- lastsubcat = _configItems[j].value.i;
+ lastsubcat = p_configs[j].value.i;
if( categoryItem && ![self isSubCategoryGeneral:lastsubcat] )
{
subCategoryItem = [categoryItem itemRepresentingSubCategory:lastsubcat];
if( categoryItem && ![self isSubCategoryGeneral:lastsubcat] )
{
subCategoryItem = [categoryItem itemRepresentingSubCategory:lastsubcat];
{
if( categoryItem && [self isSubCategoryGeneral:lastsubcat] )
{
{
if( categoryItem && [self isSubCategoryGeneral:lastsubcat] )
{
- [[categoryItem options] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&_configItems[j]]];
+ [[categoryItem options] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&p_configs[j]]];
}
else if( subCategoryItem )
{
}
else if( subCategoryItem )
{
- [[subCategoryItem options] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&_configItems[j]]];
+ [[subCategoryItem options] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&p_configs[j]]];
}
}
else if( !module_is_main( p_module) && (configType & CONFIG_ITEM))
{
}
}
else if( !module_is_main( p_module) && (configType & CONFIG_ITEM))
{
+ if( ![[subCategoryItem children] containsObject: pluginItem] )
- pluginItem = [VLCTreePluginItem pluginTreeItemWithPlugin: p_module];
- if(pluginItem) [[subCategoryItem children] addObject:pluginItem];
+ [[subCategoryItem children] addObject:pluginItem];
- [[pluginItem options] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&_configItems[j]]];
+ [[pluginItem options] addObject:[[VLCTreeLeafItem alloc] initWithConfigItem:&p_configs[j]]];
@implementation VLCTreeCategoryItem
+ (VLCTreeCategoryItem *)categoryTreeItemWithCategory:(int)category
{
@implementation VLCTreeCategoryItem
+ (VLCTreeCategoryItem *)categoryTreeItemWithCategory:(int)category
{
+ if(!config_CategoryNameGet( category )) return nil;
return [[[[self class] alloc] initWithCategory:category] autorelease];
}
- (id)initWithCategory:(int)category
{
return [[[[self class] alloc] initWithCategory:category] autorelease];
}
- (id)initWithCategory:(int)category
{
- if(!config_CategoryNameGet( category )) return nil;
NSString * name = [[VLCMain sharedInstance] localizedString: config_CategoryNameGet( category )];
NSString * name = [[VLCMain sharedInstance] localizedString: config_CategoryNameGet( category )];
- if(self = [super initWithName:name andConfigItem:nil])
+ if(self = [super initWithName:name])
{
_category = category;
//_help = [[[VLCMain sharedInstance] localizedString: config_CategoryHelpGet( category )] retain];
{
_category = category;
//_help = [[[VLCMain sharedInstance] localizedString: config_CategoryHelpGet( category )] retain];
@implementation VLCTreeSubCategoryItem
- (id)initWithSubCategory:(int)subCategory
{
@implementation VLCTreeSubCategoryItem
- (id)initWithSubCategory:(int)subCategory
{
- if(!config_CategoryNameGet( subCategory )) return nil;
NSString * name = [[VLCMain sharedInstance] localizedString: config_CategoryNameGet( subCategory )];
NSString * name = [[VLCMain sharedInstance] localizedString: config_CategoryNameGet( subCategory )];
- if(self = [super initWithName:name andConfigItem:NULL])
+ if(self = [super initWithName:name])
{
_subCategory = subCategory;
//_help = [[[VLCMain sharedInstance] localizedString: config_CategoryHelpGet( subCategory )] retain];
{
_subCategory = subCategory;
//_help = [[[VLCMain sharedInstance] localizedString: config_CategoryHelpGet( subCategory )] retain];
+ (VLCTreeSubCategoryItem *)subCategoryTreeItemWithSubCategory:(int)subCategory
{
+ (VLCTreeSubCategoryItem *)subCategoryTreeItemWithSubCategory:(int)subCategory
{
+ if(!config_CategoryNameGet( subCategory )) return nil;
return [[[[self class] alloc] initWithSubCategory:subCategory] autorelease];
}
return [[[[self class] alloc] initWithSubCategory:subCategory] autorelease];
}
@implementation VLCTreePluginItem
- (id)initWithPlugin:(module_t *)plugin
{
@implementation VLCTreePluginItem
- (id)initWithPlugin:(module_t *)plugin
{
- NSString * name = [[VLCMain sharedInstance] localizedString: module_get_name( plugin, false )];
- if(self = [super initWithName:name andConfigItem:NULL])
+ NSString * name = [[VLCMain sharedInstance] localizedString: module_get_name( plugin, false )?:""];
+ if(self = [super initWithName:name])
+ _configItems = module_config_get( plugin, &_configSize );
//_plugin = plugin;
//_help = [[[VLCMain sharedInstance] localizedString: config_CategoryHelpGet( subCategory )] retain];
}
//_plugin = plugin;
//_help = [[[VLCMain sharedInstance] localizedString: config_CategoryHelpGet( subCategory )] retain];
}
return [[[[self class] alloc] initWithPlugin:plugin] autorelease];
}
return [[[[self class] alloc] initWithPlugin:plugin] autorelease];
}
+- (void)dealloc
+{
+ module_config_free( _configItems );
+ [super dealloc];
+}
+
+- (module_config_t *)configItems
+{
+ return _configItems;
+}
+
+- (unsigned int)configSize
+{
+ return _configSize;
+}
+
@end
#pragma mark -
@implementation VLCTreeLeafItem
@end
#pragma mark -
@implementation VLCTreeLeafItem
+
+- (id)initWithConfigItem: (module_config_t *) configItem
+{
+ NSString * name = [[[VLCMain sharedInstance] localizedString:configItem->psz_name] autorelease];
+ self = [super initWithName:name];
+ if( self != nil )
+ {
+ _configItem = configItem;
+ }
+ return self;
+}
+
+- (module_config_t *)configItem
+{
+ return _configItem;
+}
@end
#pragma mark -
#pragma mark (Root class for all TreeItems)
@implementation VLCTreeItem
@end
#pragma mark -
#pragma mark (Root class for all TreeItems)
@implementation VLCTreeItem
-- (id)initWithConfigItem: (module_config_t *) configItem
-{
- NSString * name = [[VLCMain sharedInstance] localizedString:configItem->psz_name];
- return [self initWithName:name andConfigItem:configItem];
-}
-
-- (id)initWithName:(NSString*)name andConfigItem:(module_config_t *)configItem
+- (id)initWithName:(NSString*)name
{
self = [super init];
if( self != nil )
{
_name = [name retain];
{
self = [super init];
if( self != nil )
{
_name = [name retain];
- _configItem = configItem;
long i;
for( i = 0; i < [[self options] count]; i++)
{
long i;
for( i = 0; i < [[self options] count]; i++)
{
- VLCTreeItem * item = [[self options] objectAtIndex:i];
+ VLCTreeLeafItem * item = [[self options] objectAtIndex:i];
VLCConfigControl *control;
control = [VLCConfigControl newControl:[item configItem] withView:view];
VLCConfigControl *control;
control = [VLCConfigControl newControl:[item configItem] withView:view];
if(!_options) _options = [[NSMutableArray alloc] init];
return _options;
}
if(!_options) _options = [[NSMutableArray alloc] init];
return _options;
}
-
-- (module_config_t *)configItem
-{
- return _configItem;
-}
- return strdup( [[VLCMain sharedInstance] delocalizeString:
- [o_textfield stringValue]] );
+ return [[VLCMain sharedInstance] delocalizeString:
+ [o_textfield stringValue]];
continue;
unsigned int confsize;
unsigned int unused;
continue;
unsigned int confsize;
unsigned int unused;
- module_config_get( p_parser, &confsize );
+ module_config_t *p_configlist = module_config_get( p_parser, &confsize );
for ( i = 0; i < confsize; i++ )
{
for ( i = 0; i < confsize; i++ )
{
- module_config_t *p_config = module_config_get( p_parser, &unused ) + i;
+ module_config_t *p_config = &p_configlist[i];
/* Hack: required subcategory is stored in i_min */
if( p_config->i_type == CONFIG_SUBCATEGORY &&
p_config->value.i == p_item->min.i )
/* Hack: required subcategory is stored in i_min */
if( p_config->i_type == CONFIG_SUBCATEGORY &&
p_config->value.i == p_item->min.i )
[o_popup selectItem:[o_popup lastItem]];
}
}
[o_popup selectItem:[o_popup lastItem]];
}
}
+ module_config_free( p_configlist );
}
}
module_list_free( p_list );
}
}
module_list_free( p_list );
continue;
unsigned int confsize;
continue;
unsigned int confsize;
- module_config_get( p_parser, &confsize );
+ module_config_t *p_configlist = module_config_get( p_parser, &confsize );
for ( i = 0; i < confsize; i++ )
{
unsigned int unused;
for ( i = 0; i < confsize; i++ )
{
unsigned int unused;
- module_config_t *p_config = module_config_get( p_parser, &unused ) + i;
+ module_config_t *p_config = &p_configlist[i];
NSString *o_modulelongname, *o_modulename;
NSNumber *o_moduleenabled = nil;
NSString *o_modulelongname, *o_modulename;
NSNumber *o_moduleenabled = nil;
o_moduleenabled, nil]];
}
}
o_moduleenabled, nil]];
}
}
+ module_config_free( p_configlist );
}
module_list_free( p_list );
}
module_list_free( p_list );
* hotkeys settings *
********************/
const struct hotkey *p_hotkeys = p_intf->p_libvlc->p_hotkeys;
* hotkeys settings *
********************/
const struct hotkey *p_hotkeys = p_intf->p_libvlc->p_hotkeys;
+ [o_hotkeySettings release];
o_hotkeySettings = [[NSMutableArray alloc] init];
NSMutableArray *o_tempArray_desc = [[NSMutableArray alloc] init];
i = 1;
o_hotkeySettings = [[NSMutableArray alloc] init];
NSMutableArray *o_tempArray_desc = [[NSMutableArray alloc] init];
i = 1;