diff options
author | Xiao Xiangquan <xiaoxiangquan@gmail.com> | 2011-06-15 12:28:56 +0400 |
---|---|---|
committer | Xiao Xiangquan <xiaoxiangquan@gmail.com> | 2011-06-15 12:28:56 +0400 |
commit | 40981d872f0410caf1870194c8e15ebaed864dea (patch) | |
tree | adde4556e99bbc684580f028c1d962369d9f2676 /source/blender/windowmanager/intern/wm_files.c | |
parent | 68c8aecb465bf0c8e229c50958dc004bde7407b3 (diff) | |
parent | 81946b9138201800e495eb28addf254958feb1a4 (diff) |
merge from trunk r37405
Diffstat (limited to 'source/blender/windowmanager/intern/wm_files.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 50 |
1 files changed, 16 insertions, 34 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 1f005ba6021..1ac31a1786e 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -58,6 +58,8 @@ #include "BLI_linklist.h" #include "BLI_utildefines.h" +#include "BLF_api.h" + #include "DNA_anim_types.h" #include "DNA_ipo_types.h" // XXX old animation system #include "DNA_object_types.h" @@ -485,15 +487,16 @@ int WM_read_homefile(bContext *C, ReportList *reports, short from_memory) /* prevent buggy files that had G_FILE_RELATIVE_REMAP written out by mistake. Screws up autosaves otherwise * can remove this eventually, only in a 2.53 and older, now its not written */ G.fileflags &= ~G_FILE_RELATIVE_REMAP; - + + /* check userdef before open window, keymaps etc */ + wm_init_userdef(C); + /* match the read WM with current WM */ wm_window_match_do(C, &wmbase); WM_check(C); /* opens window(s), checks keymaps */ G.main->name[0]= '\0'; - wm_init_userdef(C); - /* When loading factory settings, the reset solid OpenGL lights need to be applied. */ if (!G.background) GPU_default_lights(); @@ -620,31 +623,6 @@ static void write_history(void) } } -static void do_history(char *name, ReportList *reports) -{ - char tempname1[FILE_MAXDIR+FILE_MAXFILE], tempname2[FILE_MAXDIR+FILE_MAXFILE]; - int hisnr= U.versions; - - if(U.versions==0) return; - if(strlen(name)<2) return; - - while(hisnr > 1) { - BLI_snprintf(tempname1, sizeof(tempname1), "%s%d", name, hisnr-1); - BLI_snprintf(tempname2, sizeof(tempname2), "%s%d", name, hisnr); - - if(BLI_rename(tempname1, tempname2)) - BKE_report(reports, RPT_ERROR, "Unable to make version backup"); - - hisnr--; - } - - /* is needed when hisnr==1 */ - BLI_snprintf(tempname1, sizeof(tempname1), "%s%d", name, hisnr); - - if(BLI_rename(name, tempname1)) - BKE_report(reports, RPT_ERROR, "Unable to make version backup"); -} - static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt) { /* will be scaled down, but gives some nice oversampling */ @@ -693,9 +671,11 @@ static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt) int write_crash_blend(void) { char path[FILE_MAX]; + int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on crash file */ + BLI_strncpy(path, G.main->name, sizeof(path)); BLI_replace_extension(path, sizeof(path), "_crash.blend"); - if(BLO_write_file(G.main, path, G.fileflags, NULL, NULL)) { + if(BLO_write_file(G.main, path, fileflags, NULL, NULL)) { printf("written: %s\n", path); return 1; } @@ -753,8 +733,7 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re /* blend file thumbnail */ ibuf_thumb= blend_file_thumb(CTX_data_scene(C), &thumb); - /* rename to .blend1, do this as last before write */ - do_history(filepath, reports); + fileflags |= G_FILE_HISTORY; /* write file history */ if (BLO_write_file(CTX_data_main(C), filepath, fileflags, reports, thumb)) { if(!copy) { @@ -770,7 +749,10 @@ int WM_write_file(bContext *C, const char *target, int fileflags, ReportList *re if(fileflags & G_FILE_AUTOPLAY) G.fileflags |= G_FILE_AUTOPLAY; else G.fileflags &= ~G_FILE_AUTOPLAY; - write_history(); + /* prevent background mode scripts from clobbering history */ + if(!G.background) { + write_history(); + } /* run this function after because the file cant be written before the blend is */ if (ibuf_thumb) { @@ -809,7 +791,7 @@ int WM_write_homefile(bContext *C, wmOperator *op) printf("trying to save homefile at %s ", filepath); /* force save as regular blend file */ - fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_LOCK | G_FILE_SIGN); + fileflags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_AUTOPLAY | G_FILE_LOCK | G_FILE_SIGN | G_FILE_HISTORY); if(BLO_write_file(CTX_data_main(C), filepath, fileflags, op->reports, NULL) == 0) { printf("fail\n"); @@ -883,7 +865,7 @@ void wm_autosave_timer(const bContext *C, wmWindowManager *wm, wmTimer *UNUSED(w wm_autosave_location(filepath); /* force save as regular blend file */ - fileflags = G.fileflags & ~(G_FILE_COMPRESS|G_FILE_AUTOPLAY |G_FILE_LOCK|G_FILE_SIGN); + fileflags = G.fileflags & ~(G_FILE_COMPRESS|G_FILE_AUTOPLAY |G_FILE_LOCK|G_FILE_SIGN|G_FILE_HISTORY); /* no error reporting to console */ BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL); |