diff options
-rw-r--r-- | source/blender/blenkernel/BKE_global.h | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blender_undo.c | 7 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 4 |
4 files changed, 20 insertions, 6 deletions
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index fc2ce4bf8a5..b3d0e0c9f98 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -179,6 +179,14 @@ enum { * so keep this as a flag. */ G_FILE_RECOVER_READ = (1 << 23), + /** + * On write, assign use #FileGlobal.filename, otherwise leave it blank, + * needed so files can be recovered at their original locations. + * + * \note only #BLENDER_QUIT_FILE and auto-save files include recovery information. + * As users/developers may not want their paths exposed in publicly distributed files. + */ + G_FILE_RECOVER_WRITE = (1 << 24), /** BMesh option to save as older mesh format */ /* #define G_FILE_MESH_COMPAT (1 << 26) */ /* #define G_FILE_GLSL_NO_ENV_LIGHTING (1 << 28) */ /* deprecated */ @@ -188,7 +196,7 @@ enum { * Run-time only #G.fileflags which are never read or written to/from Blend files. * This means we can change the values without worrying about do-versions. */ -#define G_FILE_FLAG_ALL_RUNTIME (G_FILE_NO_UI) +#define G_FILE_FLAG_ALL_RUNTIME (G_FILE_NO_UI | G_FILE_RECOVER_READ | G_FILE_RECOVER_WRITE) /** ENDIAN_ORDER: indicates what endianness the platform where the file was written had. */ #if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) diff --git a/source/blender/blenkernel/intern/blender_undo.c b/source/blender/blenkernel/intern/blender_undo.c index 9f8a30722c2..293b2c9c4c6 100644 --- a/source/blender/blenkernel/intern/blender_undo.c +++ b/source/blender/blenkernel/intern/blender_undo.c @@ -115,6 +115,9 @@ MemFileUndoData *BKE_memfile_undo_encode(Main *bmain, MemFileUndoData *mfu_prev) { MemFileUndoData *mfu = MEM_callocN(sizeof(MemFileUndoData), __func__); + /* Include recovery infomation since undo-data is written out as #BLENDER_QUIT_FILE. */ + const int fileflags = G.fileflags | G_FILE_RECOVER_WRITE; + /* disk save version */ if (UNDO_DISK) { static int counter = 0; @@ -129,7 +132,7 @@ MemFileUndoData *BKE_memfile_undo_encode(Main *bmain, MemFileUndoData *mfu_prev) BLI_join_dirfile(filename, sizeof(filename), BKE_tempdir_session(), numstr); /* success = */ /* UNUSED */ BLO_write_file( - bmain, filename, G.fileflags, &(const struct BlendFileWriteParams){0}, NULL); + bmain, filename, fileflags, &(const struct BlendFileWriteParams){0}, NULL); BLI_strncpy(mfu->filename, filename, sizeof(mfu->filename)); } @@ -138,7 +141,7 @@ MemFileUndoData *BKE_memfile_undo_encode(Main *bmain, MemFileUndoData *mfu_prev) if (prevfile) { BLO_memfile_clear_future(prevfile); } - /* success = */ /* UNUSED */ BLO_write_file_mem(bmain, prevfile, &mfu->memfile, G.fileflags); + /* success = */ /* UNUSED */ BLO_write_file_mem(bmain, prevfile, &mfu->memfile, fileflags); mfu->undo_size = mfu->memfile.size; } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 6fbd4b77487..4ac49d5aebb 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -870,7 +870,10 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar) fg.fileflags = (fileflags & ~G_FILE_FLAG_ALL_RUNTIME); fg.globalf = G.f; - BLI_strncpy(fg.filename, mainvar->name, sizeof(fg.filename)); + /* Write information needed for recovery. */ + if (fileflags & G_FILE_RECOVER_WRITE) { + BLI_strncpy(fg.filename, mainvar->name, sizeof(fg.filename)); + } sprintf(subvstr, "%4d", BLENDER_FILE_SUBVERSION); memcpy(fg.subvstr, subvstr, 4); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 40b32665f4b..ba40676d4cf 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -1682,8 +1682,8 @@ void wm_autosave_timer(Main *bmain, wmWindowManager *wm, wmTimer *UNUSED(wt)) } } else { - /* Save as regular blend file. */ - const int fileflags = G.fileflags & ~G_FILE_COMPRESS; + /* Save as regular blend file with recovery information. */ + const int fileflags = (G.fileflags & ~G_FILE_COMPRESS) | G_FILE_RECOVER_WRITE; ED_editors_flush_edits(bmain); |