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:
authorBastien Montagne <bastien@blender.org>2020-06-03 13:07:45 +0300
committerBastien Montagne <bastien@blender.org>2020-06-03 13:07:45 +0300
commitcda15408582e8de5b40543738b92b8fcf5e77978 (patch)
tree89c34fd35ba9f4bd8d07b7c4b26faeebf06c7fd8 /source/blender/blenloader/BLO_undofile.h
parent3384bb2c663fda4e8b2f63f37ffce7152436f0a5 (diff)
Undo: Detect/find proper memchunk for a given ID during undo step writing.
Most of the time current (based on order) system works fine, but when you add or rename (i.e. re-sort) some ID, every data/memchunk afterwards would be out of sync and hence re-stored in memory (and reported as changed). Now we are storing the ID's session_uuid in the memchunks, which allows to actually always find the first memchunk for an already existing ID stored in previous undo steps, and compare the right memory. Note that current, based-on-order system is still used almost all of the time, search in the new ghash is only performed for a few data-blocks (when needed at all). Reviewed By: brecht Maniphest Tasks: T60695 Differential Revision: https://developer.blender.org/D7877
Diffstat (limited to 'source/blender/blenloader/BLO_undofile.h')
-rw-r--r--source/blender/blenloader/BLO_undofile.h26
1 files changed, 22 insertions, 4 deletions
diff --git a/source/blender/blenloader/BLO_undofile.h b/source/blender/blenloader/BLO_undofile.h
index f280b8f3b9c..175aa4ab9d0 100644
--- a/source/blender/blenloader/BLO_undofile.h
+++ b/source/blender/blenloader/BLO_undofile.h
@@ -26,6 +26,7 @@
*/
struct Scene;
+struct GHash;
typedef struct {
void *next, *prev;
@@ -38,6 +39,9 @@ typedef struct {
* detect unchanged IDs).
* Defined when writing the next step (i.e. last undo step has those always false). */
bool is_identical_future;
+ /** Session uuid of the ID being curently written (MAIN_ID_SESSION_UUID_UNSET when not writing
+ * ID-related data). Used to find matching chunks in previous memundo step. */
+ uint id_session_uuid;
} MemFileChunk;
typedef struct MemFile {
@@ -45,6 +49,17 @@ typedef struct MemFile {
size_t size;
} MemFile;
+typedef struct MemFileWriteData {
+ MemFile *written_memfile;
+ MemFile *reference_memfile;
+
+ uint current_id_session_uuid;
+ MemFileChunk *reference_current_chunk;
+
+ /** Maps an ID session uuid to its first reference MemFileChunk, if existing. */
+ struct GHash *id_session_uuid_mapping;
+} MemFileWriteData;
+
typedef struct MemFileUndoData {
char filename[1024]; /* FILE_MAX */
MemFile memfile;
@@ -52,10 +67,13 @@ typedef struct MemFileUndoData {
} MemFileUndoData;
/* actually only used writefile.c */
-extern void memfile_chunk_add(MemFile *memfile,
- const char *buf,
- unsigned int size,
- MemFileChunk **compchunk_step);
+
+void BLO_memfile_write_init(MemFileWriteData *mem_data,
+ MemFile *written_memfile,
+ MemFile *reference_memfile);
+void BLO_memfile_write_finalize(MemFileWriteData *mem_data);
+
+void BLO_memfile_chunk_add(MemFileWriteData *mem_data, const char *buf, unsigned int size);
/* exports */
extern void BLO_memfile_free(MemFile *memfile);