[vlc-commits] macosx: fix broken first time settings setup

David Fuhrmann git at videolan.org
Thu Jun 19 20:17:20 CEST 2014


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Thu Jun 19 20:14:16 2014 +0200| [b8c3c7d477c3e0155dffd48a5b6ac9bfce1f569b] | committer: 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

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b8c3c7d477c3e0155dffd48a5b6ac9bfce1f569b
---

 modules/gui/macosx/intf.m |   22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 8f46abb..6c12719 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -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);



More information about the vlc-commits mailing list