Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-03-15 05:30:43 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-03-15 06:48:17 +0300
commit88b24bc6bbbf35bde00c55834330b56708f25897 (patch)
treee236a0d29251c5f83d92c67ee3e577c4dde1516c
parentd3b4ff6eaa1cb155adf4b2aad4775746bc3ca6df (diff)
Writefile: only include recovery info in auto-save & quit.blend
Previously all blend files included the path they were saved, causing files distributed publicly to include users local paths. This also included developers home directories for startup & userprefs defaults & app-templates bundled with Blender. Now recovery information is only written for auto-save & quit.blend since this is the only time they're intended to be used.
-rw-r--r--source/blender/blenkernel/BKE_global.h10
-rw-r--r--source/blender/blenkernel/intern/blender_undo.c7
-rw-r--r--source/blender/blenloader/intern/writefile.c5
-rw-r--r--source/blender/windowmanager/intern/wm_files.c4
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);