Commit a4cfffcc 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

(cherry picked from commit b8c3c7d477c3e0155dffd48a5b6ac9bfce1f569b)
Signed-off-by: default avatarDavid Fuhrmann <dfuhrmann@videolan.org>
parent a02da20e
......@@ -1679,6 +1679,14 @@ static VLCMain *_o_sharedMainInstance = nil;
static NSString * kVLCPreferencesVersion = @"VLCPreferencesVersion";
static const int kCurrentPreferencesVersion = 3;
+ (void)initialize
{
NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCurrentPreferencesVersion]
forKey:kVLCPreferencesVersion];
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
}
- (void)resetAndReinitializeUserDefaults
{
// note that [NSUserDefaults resetStandardUserDefaults] will NOT correctly reset to the defaults
......@@ -1695,6 +1703,13 @@ static const int kCurrentPreferencesVersion = 3;
{
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
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)
return;
......@@ -1717,13 +1732,6 @@ static const int kCurrentPreferencesVersion = 3;
if (!libraries || [libraries count] == 0) return;
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?"),
_NS("We just found an older version of VLC's preferences files."),
_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