Commit b8c3c7d4 authored by David Fuhrmann's avatar David Fuhrmann

macosx: fix broken first time settings setup

Handling with *.plist on the file system should really
be avoided, as its not safe at all. Thus the current
default version is set the right way now.

close #11625
parent 0213b4e2
...@@ -1679,6 +1679,14 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -1679,6 +1679,14 @@ static VLCMain *_o_sharedMainInstance = nil;
static NSString * kVLCPreferencesVersion = @"VLCPreferencesVersion"; static NSString * kVLCPreferencesVersion = @"VLCPreferencesVersion";
static const int kCurrentPreferencesVersion = 3; static const int kCurrentPreferencesVersion = 3;
+ (void)initialize
{
NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCurrentPreferencesVersion]
forKey:kVLCPreferencesVersion];
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
}
- (void)resetAndReinitializeUserDefaults - (void)resetAndReinitializeUserDefaults
{ {
// note that [NSUserDefaults resetStandardUserDefaults] will NOT correctly reset to the defaults // note that [NSUserDefaults resetStandardUserDefaults] will NOT correctly reset to the defaults
...@@ -1695,6 +1703,13 @@ static const int kCurrentPreferencesVersion = 3; ...@@ -1695,6 +1703,13 @@ static const int kCurrentPreferencesVersion = 3;
{ {
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
int version = [defaults integerForKey:kVLCPreferencesVersion]; int version = [defaults integerForKey:kVLCPreferencesVersion];
/*
* Store version explicitely in file, for ease of debugging.
* Otherwise, the value will be just defined at app startup,
* as initialized above.
*/
[defaults setInteger:version forKey:kVLCPreferencesVersion];
if (version >= kCurrentPreferencesVersion) if (version >= kCurrentPreferencesVersion)
return; return;
...@@ -1717,13 +1732,6 @@ static const int kCurrentPreferencesVersion = 3; ...@@ -1717,13 +1732,6 @@ static const int kCurrentPreferencesVersion = 3;
if (!libraries || [libraries count] == 0) return; if (!libraries || [libraries count] == 0) return;
NSString * preferences = [[libraries objectAtIndex:0] stringByAppendingPathComponent:@"Preferences"]; NSString * preferences = [[libraries objectAtIndex:0] stringByAppendingPathComponent:@"Preferences"];
/* File not found, don't attempt anything */
if (![[NSFileManager defaultManager] fileExistsAtPath:[preferences stringByAppendingPathComponent:@"org.videolan.vlc"]] &&
![[NSFileManager defaultManager] fileExistsAtPath:[preferences stringByAppendingPathComponent:@"org.videolan.vlc.plist"]]) {
[defaults setInteger:kCurrentPreferencesVersion forKey:kVLCPreferencesVersion];
return;
}
int res = NSRunInformationalAlertPanel(_NS("Remove old preferences?"), int res = NSRunInformationalAlertPanel(_NS("Remove old preferences?"),
_NS("We just found an older version of VLC's preferences files."), _NS("We just found an older version of VLC's preferences files."),
_NS("Move To Trash and Relaunch VLC"), _NS("Ignore"), nil, nil); _NS("Move To Trash and Relaunch VLC"), _NS("Ignore"), nil, nil);
......
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