diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-04-12 08:23:38 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-04-12 08:23:38 +0400 |
commit | 8fd1d53a311b27f5088e9c81ed192b425bcd1837 (patch) | |
tree | 9282c7c992f3b8244b10bf8e64ff03b13761aafc | |
parent | 3a73a75e844cf067c92f8c7f8d18065bc413b7b6 (diff) |
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.
-rw-r--r-- | release/scripts/startup/bl_operators/wm.py | 31 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 29 |
2 files changed, 28 insertions, 32 deletions
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 3ecdb70d2a1..3e0b30c7b6a 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -918,23 +918,24 @@ class WM_OT_copy_prev_settings(bpy.types.Operator): 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) - 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(): diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 171ff239c69..dacfba48ee9 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1115,23 +1115,17 @@ static int wm_resource_check_prev(void) // 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; + } + else { + return (BLI_get_folder_version(BLENDER_RESOURCE_PATH_USER, BLENDER_VERSION - 1, TRUE) != NULL); } - - return FALSE; } static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(arg)) @@ -1206,14 +1200,15 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar 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); |