change behavior of restoring old settings
[blender-staging.git] / release / scripts / startup / bl_operators / wm.py
index 3ecdb70d2a1bc2e00cb38d5ab03b70d7d9a30880..3e0b30c7b6a802089a43c97d64e8e98f5234a512 100644 (file)
@@ -918,23 +918,24 @@ class WM_OT_copy_prev_settings(bpy.types.Operator):
         import os
         import shutil
         ver = bpy.app.version
         import os
         import shutil
         ver = bpy.app.version
-        ver_prev = ((ver[0] * 100) + ver[1]) - 1
-        ver_prev = ver_prev // 100, ver_prev % 100
-        for res in ('USER', 'LOCAL'):
-            path_src = bpy.utils.resource_path(res, ver_prev[0], ver_prev[1])
-            path_dst = bpy.utils.resource_path(res)
-
-            if os.path.isdir(path_dst):
-                self.report({'ERROR'}, "Path %r exists" % path_dst)
-                return {'CANCELLED'}
-            else:
-                break
-
-        if os.path.isdir(path_src):
+        ver_old = ((ver[0] * 100) + ver[1]) - 1
+        path_src = bpy.utils.resource_path('USER', ver_old // 100, ver_old % 100)
+        path_dst = bpy.utils.resource_path('USER')
+
+        if os.path.isdir(path_dst):
+            self.report({'ERROR'}, "Target path %r exists" % path_dst)
+        elif not os.path.isdir(path_src):
+            self.report({'ERROR'}, "Source path %r exists" % path_src)
+        else:
             shutil.copytree(path_src, path_dst)
             shutil.copytree(path_src, path_dst)
-            bpy.ops.wm.read_homefile()
+            # dont loose users work if they open the splash later.
+            if bpy.data.is_saved is bpy.data.is_dirty is False:
+                bpy.ops.wm.read_homefile()
+            else:
+                self.report({'INFO'}, "Reload Start-Up file to restore settings.")
+            return {'FINISHED'}
 
 
-        return {'FINISHED'}
+        return {'CANCELLED'}
 
 
 def _webbrowser_bug_fix():
 
 
 def _webbrowser_bug_fix():