[Bf-blender-cvs] [7d1c7a6485f] master: Fix splash screen not showing button to load config from 2.83 into 2.90

Brecht Van Lommel noreply at git.blender.org
Wed Apr 15 15:55:40 CEST 2020


Commit: 7d1c7a6485f7c37b3ad49953df1164a022cb2fe5
Author: Brecht Van Lommel
Date:   Wed Apr 15 15:51:08 2020 +0200
Branches: master
https://developer.blender.org/rB7d1c7a6485f7c37b3ad49953df1164a022cb2fe5

Fix splash screen not showing button to load config from 2.83 into 2.90

===================================================================

M	release/scripts/startup/bl_operators/userpref.py
M	release/scripts/startup/bl_operators/wm.py

===================================================================

diff --git a/release/scripts/startup/bl_operators/userpref.py b/release/scripts/startup/bl_operators/userpref.py
index f78ee026927..a4c19d5a8da 100644
--- a/release/scripts/startup/bl_operators/userpref.py
+++ b/release/scripts/startup/bl_operators/userpref.py
@@ -110,20 +110,30 @@ class PREFERENCES_OT_copy_prev(Operator):
     bl_idname = "preferences.copy_prev"
     bl_label = "Copy Previous Settings"
 
-    @staticmethod
-    def previous_version():
-        ver = bpy.app.version
-        ver_old = ((ver[0] * 100) + ver[1]) - 1
-        return ver_old // 100, ver_old % 100
+    @classmethod
+    def _old_version_path(cls, version):
+        return bpy.utils.resource_path('USER', version[0], version[1])
 
-    @staticmethod
-    def _old_path():
-        ver = bpy.app.version
-        ver_old = ((ver[0] * 100) + ver[1]) - 1
-        return bpy.utils.resource_path('USER', ver_old // 100, ver_old % 100)
+    @classmethod
+    def previous_version(cls):
+        # Find config folder from previous version.
+        import os
+        version = bpy.app.version
+        version_old = ((version[0] * 100) + version[1]) - 1
+        while version_old % 10 > 0:
+            version_split = version_old // 100, version_old % 100
+            if os.path.isdir(cls._old_version_path(version_split)):
+                return version_split
+            version_old = version_old - 1
+        return None
 
-    @staticmethod
-    def _new_path():
+    @classmethod
+    def _old_path(cls):
+        version_old = cls.previous_version()
+        return cls._old_version_path(version_old) if version_old else None
+
+    @classmethod
+    def _new_path(cls):
         return bpy.utils.resource_path('USER')
 
     @classmethod
@@ -132,6 +142,8 @@ class PREFERENCES_OT_copy_prev(Operator):
 
         old = cls._old_path()
         new = cls._new_path()
+        if not old:
+            return False
 
         # Disable operator in case config path is overridden with environment
         # variable. That case has no automatic per-version configuration.
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index f0f3ba14d92..99785fe0c4b 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -2483,8 +2483,8 @@ class WM_MT_splash(Menu):
         row = layout.row()
 
         sub = row.row()
-        if bpy.types.PREFERENCES_OT_copy_prev.poll(context):
-            old_version = bpy.types.PREFERENCES_OT_copy_prev.previous_version()
+        old_version = bpy.types.PREFERENCES_OT_copy_prev.previous_version()
+        if bpy.types.PREFERENCES_OT_copy_prev.poll(context) and old_version:
             sub.operator("preferences.copy_prev", text="Load %d.%d Settings" % old_version)
             sub.operator("wm.save_userpref", text="Save New Settings")
         else:



More information about the Bf-blender-cvs mailing list