[Bf-blender-cvs] [9173ca9e97b] undo-experiments: Some temp prints to understand how unod works...

Bastien Montagne noreply at git.blender.org
Fri Aug 30 19:10:02 CEST 2019


Commit: 9173ca9e97b57444fa86490daa039b426666639a
Author: Bastien Montagne
Date:   Mon Aug 26 09:40:08 2019 +0200
Branches: undo-experiments
https://developer.blender.org/rB9173ca9e97b57444fa86490daa039b426666639a

Some temp prints to understand how unod works...

===================================================================

M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/readfile.h

===================================================================

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index a133dd30c9b..48032391045 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -1246,6 +1246,10 @@ static int fd_read_from_memfile(FileData *filedata, void *buffer, uint size)
       totread += readsize;
       filedata->file_offset += readsize;
       seek += readsize;
+      filedata->are_memchunks_identical &= chunk->is_identical;
+      if (!chunk->is_identical) {
+        printf("%s: found a non-identical memfile chunk...\n", __func__);
+      }
     } while (totread < size);
 
     return totread;
@@ -9142,7 +9146,12 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const int ta
   }
 
   /* read libblock */
+  fd->are_memchunks_identical = true;
+  printf("%s: Reading a struct...\n", __func__);
   id = read_struct(fd, bhead, "lib block");
+  printf("\tfor ID %s: are_memchunks_identical: %d\n",
+         id ? id->name : "NONE",
+         fd->are_memchunks_identical);
 
   if (id) {
     const short idcode = GS(id->name);
diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h
index 10ee3d52a74..b272f41a829 100644
--- a/source/blender/blenloader/intern/readfile.h
+++ b/source/blender/blenloader/intern/readfile.h
@@ -78,6 +78,11 @@ typedef struct FileData {
   const char *buffer;
   /** Variables needed for reading from memfile (undo). */
   struct MemFile *memfile;
+  /** Whether all data read from memfile so far was identical
+   * (i.e. shared with some previous undo step).
+   * Updated by `fd_read_from_memfile()`, user is responsible to reset it to true when needed.
+   * Used to detected unchanged IDs. */
+  bool are_memchunks_identical;
 
   /** Variables needed for reading from file. */
   gzFile gzfiledes;



More information about the Bf-blender-cvs mailing list