Fix regression in r59316
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 7 Oct 2013 16:06:15 +0000 (16:06 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 7 Oct 2013 16:06:15 +0000 (16:06 +0000)
Different version could be passed here, added check
cached path is calculated with the proper one.

intern/ghost/intern/GHOST_SystemPathsX11.cpp

index 50eb68d..e2d9733 100644 (file)
@@ -74,13 +74,16 @@ const GHOST_TUns8 *GHOST_SystemPathsX11::getSystemDir(int, const char *versionst
 const GHOST_TUns8 *GHOST_SystemPathsX11::getUserDir(int version, const char *versionstr) const
 {
        static string user_path = "";
+       static int last_version = 0;
 
        /* in blender 2.64, we migrate to XDG. to ensure the copy previous settings
         * operator works we give a different path depending on the requested version */
        if (version < 264) {
-               if (user_path.empty()) {
+               if (user_path.empty() || last_version != version) {
                        const char *home = getenv("HOME");
 
+                       last_version = version;
+
                        if (home) {
                                user_path = string(home) + "/.blender/" + versionstr;
                        }
@@ -91,9 +94,11 @@ const GHOST_TUns8 *GHOST_SystemPathsX11::getUserDir(int version, const char *ver
                return (GHOST_TUns8 *)user_path.c_str();
        }
        else {
-               if (user_path.empty()) {
+               if (user_path.empty() || last_version != version) {
                        const char *home = getenv("XDG_CONFIG_HOME");
 
+                       last_version = version;
+
                        if (home) {
                                user_path = string(home) + "/blender/" + versionstr;
                        }