Commit d864f1ca authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: fixed broken preferences on launch when starting 2.0.2 for the first time

'control' and 'extraintf' will be checked for occurences of 'macosx', which, if found, in turn will be removed. Other contents of these settings won't be touched. Same for all the other prefs.
parent 88afb043
......@@ -1869,10 +1869,50 @@ unsigned int CocoaKeyToVLC( unichar i_key )
- (void)_removeOldPreferences
{
static NSString * kVLCPreferencesVersion = @"VLCPreferencesVersion";
static const int kCurrentPreferencesVersion = 1;
static const int kCurrentPreferencesVersion = 2;
int version = [[NSUserDefaults standardUserDefaults] integerForKey:kVLCPreferencesVersion];
if( version >= kCurrentPreferencesVersion ) return;
if( version == 1 )
{
NSMutableString * o_workString = [[NSMutableString alloc] initWithFormat:@"%s", config_GetPsz( VLCIntf, "extraintf" )];
NSRange returnedRange;
NSRange fullRange;
BOOL b_needsRestart = NO;
#define fixpref( pref ) \
o_workString = [[NSMutableString alloc] initWithFormat:@"%s", config_GetPsz( VLCIntf, pref )]; \
if ([o_workString length] > 0) \
{ \
returnedRange = [o_workString rangeOfString:@"macosx" options: NSCaseInsensitiveSearch]; \
if (returnedRange.location != NSNotFound) \
{ \
fullRange = NSMakeRange( 0, [o_workString length] ); \
[o_workString replaceOccurrencesOfString:@":macosx" withString:@"" options: NSCaseInsensitiveSearch range: fullRange]; \
fullRange = NSMakeRange( 0, [o_workString length] ); \
[o_workString replaceOccurrencesOfString:@"macosx:" withString:@"" options: NSCaseInsensitiveSearch range: fullRange]; \
fullRange = NSMakeRange( 0, [o_workString length] ); \
[o_workString replaceOccurrencesOfString:@"macosx" withString:@"" options: NSCaseInsensitiveSearch range: fullRange]; \
config_PutPsz( VLCIntf, pref, [o_workString UTF8String] ); \
b_needsRestart = YES; \
} \
} \
[o_workString release]
fixpref( "control" );
fixpref( "extraintf" );
#undef fixpref
[[NSUserDefaults standardUserDefaults] setInteger:kCurrentPreferencesVersion forKey:kVLCPreferencesVersion];
[[NSUserDefaults standardUserDefaults] synchronize];
if (!b_needsRestart)
return;
else
config_SaveConfigFile( VLCIntf ); // we need to do manually, since we won't quit libvlc cleanly
}
else
{
NSArray *libraries = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
NSUserDomainMask, YES);
if( !libraries || [libraries count] == 0) return;
......@@ -1905,6 +1945,7 @@ unsigned int CocoaKeyToVLC( unichar i_key )
[[NSUserDefaults standardUserDefaults] setInteger:kCurrentPreferencesVersion forKey:kVLCPreferencesVersion];
[[NSUserDefaults standardUserDefaults] synchronize];
}
/* Relaunch now */
const char * path = [[[NSBundle mainBundle] executablePath] UTF8String];
......
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