Commit 4fac1895 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: improve the handling of broken prefs and make sure that the user is...

macosx: improve the handling of broken prefs and make sure that the user is unable to re-break them without using the command-line or a text editor
parent bfd2978e
......@@ -75,4 +75,6 @@
- (void)setAspectRatioLocked:(BOOL)b_value;
- (BOOL)aspectRatioIsLocked;
- (void)toggleFullscreen;
- (BOOL)fixPreferences;
@end
......@@ -638,4 +638,41 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
}
}
#pragma mark -
#pragma mark uncommon stuff
- (BOOL)fixPreferences
{
NSMutableString * o_workString;
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) \
{ \
if ([o_workString isEqualToString:@"macosx"]) \
[o_workString setString:@""]; \
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
return b_needsRestart;
}
@end
......@@ -1899,38 +1899,10 @@ unsigned int CocoaKeyToVLC( unichar i_key )
if( version == 1 )
{
NSMutableString * o_workString;
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)
if (![[VLCCoreInteraction sharedInstance] fixPreferences])
return;
else
config_SaveConfigFile( VLCIntf ); // we need to do manually, since we won't quit libvlc cleanly
......@@ -1959,7 +1931,7 @@ unsigned int CocoaKeyToVLC( unichar i_key )
return;
}
NSArray * ourPreferences = [NSArray arrayWithObjects:@"org.videolan.vlc.plist", @"VLC", nil];
NSArray * ourPreferences = [NSArray arrayWithObjects:@"org.videolan.vlc.plist", @"VLC", @"org.videolan.vlc", nil];
/* Move the file to trash so that user can find them later */
[[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:preferences destination:nil files:ourPreferences tag:0];
......
......@@ -57,6 +57,7 @@
#import "prefs.h"
#import "simple_prefs.h"
#import "prefs_widgets.h"
#import "CoreInteraction.h"
#import <vlc_keys.h>
#import <vlc_modules.h>
#import <vlc_plugin.h>
......@@ -213,6 +214,7 @@ static VLCPrefs *_o_sharedMainInstance = nil;
{
/* TODO: call savePrefs on Root item */
[_rootTreeItem applyChanges];
[[VLCCoreInteraction sharedInstance] fixPreferences];
config_SaveConfigFile( p_intf );
[o_prefs_window orderOut:self];
}
......
......@@ -1011,6 +1011,8 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
b_hotkeyChanged = NO;
}
[[VLCCoreInteraction sharedInstance] fixPreferences];
/* okay, let's save our changes to vlcrc */
config_SaveConfigFile( p_intf );
......
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