[vlc-commits] macosx: fixed volume normalizer prefs and crash when saving the Growl option in combination with some config sets
Felix Paul Kühne
git at videolan.org
Sun Jun 5 19:19:44 CEST 2011
vlc/vlc-1.1 | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sun Jun 5 19:11:36 2011 +0200| [0b37b556d9156297f94d1194b15afd021a9d8ef1] | committer: Felix Paul Kühne
macosx: fixed volume normalizer prefs and crash when saving the Growl option in combination with some config sets
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=0b37b556d9156297f94d1194b15afd021a9d8ef1
---
modules/gui/macosx/simple_prefs.m | 61 +++++++++++++++++++-----------------
1 files changed, 32 insertions(+), 29 deletions(-)
diff --git a/modules/gui/macosx/simple_prefs.m b/modules/gui/macosx/simple_prefs.m
index e5737cd..72f43a8 100644
--- a/modules/gui/macosx/simple_prefs.m
+++ b/modules/gui/macosx/simple_prefs.m
@@ -492,7 +492,7 @@ static inline char * __config_GetLabel( vlc_object_t *p_this, const char *psz_na
psz_tmp = config_GetPsz( p_intf, "audio-filter" );
if( psz_tmp )
{
- [o_audio_norm_ckb setState: (NSInteger)strstr( psz_tmp, "volnorm" )];
+ [o_audio_norm_ckb setState: (NSInteger)strstr( psz_tmp, "normvol" )];
[o_audio_norm_fld setEnabled: [o_audio_norm_ckb state]];
[o_audio_norm_stepper setEnabled: [o_audio_norm_ckb state]];
free( psz_tmp );
@@ -791,7 +791,8 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
- (void)saveChangedSettings
{
- char *psz_tmp;
+ NSString *tmpString;
+ NSRange tmpRange;
int i;
#define SaveIntList( object, name ) save_int_list( p_intf, object, name )
@@ -800,6 +801,8 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
#define SaveModuleList( object, name ) save_module_list( p_intf, object, name )
+#define getString( name ) [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, name )]
+
/**********************
* interface settings *
**********************/
@@ -814,25 +817,25 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
config_PutInt( p_intf, "macosx-mediakeys", [o_intf_mediakeys_ckb state] );
if( [o_intf_enableGrowl_ckb state] == NSOnState )
{
- psz_tmp = config_GetPsz( p_intf, "control" );
- if(! psz_tmp)
- config_PutPsz( p_intf, "control", "growl" );
- else if( (NSInteger)strstr( psz_tmp, "control" ) == NO )
+ tmpString = getString( "control" );
+ tmpRange = [tmpString rangeOfString:@"growl"];
+ if( [tmpString length] > 0 && tmpRange.location == NSNotFound )
{
- psz_tmp = (char *)[[NSString stringWithFormat: @"%s:growl", psz_tmp] UTF8String];
- config_PutPsz( p_intf, "control", psz_tmp );
- free( psz_tmp );
+ tmpString = [tmpString stringByAppendingString: @":growl"];
+ config_PutPsz( p_intf, "control", [tmpString UTF8String] );
}
+ else
+ config_PutPsz( p_intf, "control", "growl" );
}
else
{
- psz_tmp = config_GetPsz( p_intf, "control" );
- if( psz_tmp )
+ tmpString = getString( "control" );
+ if(! [tmpString isEqualToString:@""] )
{
- psz_tmp = (char *)[[[NSString stringWithUTF8String: psz_tmp] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":growl"]] UTF8String];
- psz_tmp = (char *)[[[NSString stringWithUTF8String: psz_tmp] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"growl:"]] UTF8String];
- psz_tmp = (char *)[[[NSString stringWithUTF8String: psz_tmp] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"growl"]] UTF8String];
- config_PutPsz( p_intf, "control", psz_tmp );
+ tmpString = [tmpString stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":growl"]];
+ tmpString = [tmpString stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"growl:"]];
+ tmpString = [tmpString stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"growl"]];
+ config_PutPsz( p_intf, "control", [tmpString UTF8String] );
}
}
@@ -876,25 +879,25 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
if( [o_audio_norm_ckb state] == NSOnState )
{
- psz_tmp = config_GetPsz( p_intf, "audio-filter" );
- if(! psz_tmp)
- config_PutPsz( p_intf, "audio-filter", "volnorm" );
- else if( (NSInteger)strstr( psz_tmp, "normvol" ) == NO )
+ tmpString = getString( "audio-filter" );
+ tmpRange = [tmpString rangeOfString:@"normvol"];
+ if( [tmpString length] > 0 && tmpRange.location == NSNotFound )
{
- psz_tmp = (char *)[[NSString stringWithFormat: @"%s:volnorm", psz_tmp] UTF8String];
- config_PutPsz( p_intf, "audio-filter", psz_tmp );
- free( psz_tmp );
+ tmpString = [tmpString stringByAppendingString: @":normvol"];
+ config_PutPsz( p_intf, "audio-filter", [tmpString UTF8String] );
}
+ else
+ config_PutPsz( p_intf, "audio-filter", "normvol" );
}
else
{
- psz_tmp = config_GetPsz( p_intf, "audio-filter" );
- if( psz_tmp )
+ tmpString = getString( "audio-filter" );
+ if(! [tmpString isEqualToString:@""] )
{
- psz_tmp = (char *)[[[NSString stringWithUTF8String: psz_tmp] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":volnorm"]] UTF8String];
- psz_tmp = (char *)[[[NSString stringWithUTF8String: psz_tmp] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"volnorm:"]] UTF8String];
- psz_tmp = (char *)[[[NSString stringWithUTF8String: psz_tmp] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"volnorm"]] UTF8String];
- config_PutPsz( p_intf, "audio-filter", psz_tmp );
+ tmpString = [tmpString stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":normvol"]];
+ tmpString = [tmpString stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"normvol:"]];
+ tmpString = [tmpString stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"normvol"]];
+ config_PutPsz( p_intf, "audio-filter", [tmpString UTF8String] );
}
}
config_PutFloat( p_intf, "norm-max-level", [o_audio_norm_fld floatValue] );
@@ -919,7 +922,7 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
/* okay, let's save our changes to vlcrc */
i = config_SaveConfigFile( p_intf, "main" );
i = i + config_SaveConfigFile( p_intf, "audioscrobbler" );
- i = i + config_SaveConfigFile( p_intf, "volnorm" );
+ i = i + config_SaveConfigFile( p_intf, "normvol" );
if( i != 0 )
{
More information about the vlc-commits
mailing list