[vlc-commits] 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
Felix Paul Kühne
git at videolan.org
Fri May 11 13:05:10 CEST 2012
vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Fri May 11 13:05:03 2012 +0200| [4fac18958067cc3506413ae1d690910a1994506b] | committer: Felix Paul Kühne
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
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4fac18958067cc3506413ae1d690910a1994506b
---
modules/gui/macosx/CoreInteraction.h | 2 +
modules/gui/macosx/CoreInteraction.m | 37 ++++++++++++++++++++++++++++++++++
modules/gui/macosx/intf.m | 32 +---------------------------
modules/gui/macosx/prefs.m | 2 +
modules/gui/macosx/simple_prefs.m | 2 +
5 files changed, 45 insertions(+), 30 deletions(-)
diff --git a/modules/gui/macosx/CoreInteraction.h b/modules/gui/macosx/CoreInteraction.h
index 5c80635..abe0d86 100644
--- a/modules/gui/macosx/CoreInteraction.h
+++ b/modules/gui/macosx/CoreInteraction.h
@@ -75,4 +75,6 @@
- (void)setAspectRatioLocked:(BOOL)b_value;
- (BOOL)aspectRatioIsLocked;
- (void)toggleFullscreen;
+
+- (BOOL)fixPreferences;
@end
diff --git a/modules/gui/macosx/CoreInteraction.m b/modules/gui/macosx/CoreInteraction.m
index cc3a075..475c389 100644
--- a/modules/gui/macosx/CoreInteraction.m
+++ b/modules/gui/macosx/CoreInteraction.m
@@ -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
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index f735f68..a70592c 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -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];
diff --git a/modules/gui/macosx/prefs.m b/modules/gui/macosx/prefs.m
index 54732f2..cbf2d26 100644
--- a/modules/gui/macosx/prefs.m
+++ b/modules/gui/macosx/prefs.m
@@ -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];
}
diff --git a/modules/gui/macosx/simple_prefs.m b/modules/gui/macosx/simple_prefs.m
index 5fb4a13..996d4c7 100644
--- a/modules/gui/macosx/simple_prefs.m
+++ b/modules/gui/macosx/simple_prefs.m
@@ -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 );
More information about the vlc-commits
mailing list