[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36106] trunk/blender: change behavior of restoring old settings

Campbell Barton ideasman42 at gmail.com
Tue Apr 12 06:23:42 CEST 2011


Revision: 36106
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36106
Author:   campbellbarton
Date:     2011-04-12 04:23:38 +0000 (Tue, 12 Apr 2011)
Log Message:
-----------
change behavior of restoring old settings
- only attempt to restore old 'user' settings (not local), since bundled blender's always use their own settings.
- only automatically run 'bpy.ops.wm.read_homefile()' after copying files if the user hasnt alreadt started making changes in the blend file.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_operators/wm.py
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: trunk/blender/release/scripts/startup/bl_operators/wm.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/wm.py	2011-04-12 01:56:03 UTC (rev 36105)
+++ trunk/blender/release/scripts/startup/bl_operators/wm.py	2011-04-12 04:23:38 UTC (rev 36106)
@@ -918,25 +918,26 @@
         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)
+        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'}, "Path %r exists" % path_dst)
-                return {'CANCELLED'}
+        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)
+            # 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:
-                break
+                self.report({'INFO'}, "Reload Start-Up file to restore settings.")
+            return {'FINISHED'}
 
-        if os.path.isdir(path_src):
-            shutil.copytree(path_src, path_dst)
-            bpy.ops.wm.read_homefile()
+        return {'CANCELLED'}
 
-        return {'FINISHED'}
 
-
 def _webbrowser_bug_fix():
     # test for X11
     import os

Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2011-04-12 01:56:03 UTC (rev 36105)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2011-04-12 04:23:38 UTC (rev 36106)
@@ -1115,23 +1115,17 @@
 	// if(res) printf("USER: %s\n", res);
 
 	if(res == NULL) {
+		/* with a local dir, copying old files isnt useful since local dir get priority for config */
 		res= BLI_get_folder_version(BLENDER_RESOURCE_PATH_LOCAL, BLENDER_VERSION, TRUE);
 	}
 
 	// if(res) printf("LOCAL: %s\n", res);
-
-	if(res == NULL) {
-		int res_dir[]= {BLENDER_RESOURCE_PATH_USER, BLENDER_RESOURCE_PATH_LOCAL, -1};
-		int i= 0;
-
-		for(i= 0; res_dir[i] != -1; i++) {
-			if(BLI_get_folder_version(res_dir[i], BLENDER_VERSION - 1, TRUE)) {
-				return TRUE;
-			}
-		}
+	if(res) {
+		return FALSE;
 	}
-
-	return FALSE;
+	else {
+		return (BLI_get_folder_version(BLENDER_RESOURCE_PATH_USER, BLENDER_VERSION - 1, TRUE) != NULL);
+	}
 }
 
 static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(arg))
@@ -1206,16 +1200,17 @@
 	uiItemL(col, "", ICON_NONE);
 
 	col = uiLayoutColumn(split, 0);
-	uiItemL(col, "Recent", ICON_NONE);
-	for(recent = G.recent_files.first, i=0; (i<5) && (recent); recent = recent->next, i++) {
-		uiItemStringO(col, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
-	}
 
 	if(wm_resource_check_prev()) {
-		uiItemS(col);
 		uiItemO(col, NULL, ICON_NEW, "WM_OT_copy_prev_settings");
+		uiItemS(col);
 	}
 
+	uiItemL(col, "Recent", ICON_NONE);
+	for(recent = G.recent_files.first, i=0; (i<5) && (recent); recent = recent->next, i++) {
+		uiItemStringO(col, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
+	}
+
 	uiItemS(col);
 	uiItemO(col, NULL, ICON_RECOVER_LAST, "WM_OT_recover_last_session");
 	uiItemL(col, "", ICON_NONE);




More information about the Bf-blender-cvs mailing list