[Bf-blender-cvs] [556bbed6ce7] undo-experiments-idnames: Merge branch 'undo-experiments' into undo-experiments-idnames
Bastien Montagne
noreply at git.blender.org
Fri Jan 10 12:07:13 CET 2020
Commit: 556bbed6ce7a179330d665508afe6b44b001c380
Author: Bastien Montagne
Date: Fri Jan 10 12:06:50 2020 +0100
Branches: undo-experiments-idnames
https://developer.blender.org/rB556bbed6ce7a179330d665508afe6b44b001c380
Merge branch 'undo-experiments' into undo-experiments-idnames
Conflicts:
source/blender/blenkernel/BKE_blender_undo.h
source/blender/blenkernel/intern/blender_undo.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/undo/memfile_undo.c
===================================================================
===================================================================
diff --cc source/blender/blenkernel/BKE_blender_undo.h
index f869790decf,ae408f2f69a..4ecedbbfc1e
--- a/source/blender/blenkernel/BKE_blender_undo.h
+++ b/source/blender/blenkernel/BKE_blender_undo.h
@@@ -33,7 -33,7 +33,8 @@@ struct bContext
struct MemFileUndoData *BKE_memfile_undo_encode(struct Main *bmain,
struct MemFileUndoData *mfu_prev);
bool BKE_memfile_undo_decode(struct MemFileUndoData *mfu,
+ const int undo_direction,
+ const bool use_old_bmain_data,
struct bContext *C);
void BKE_memfile_undo_free(struct MemFileUndoData *mfu);
diff --cc source/blender/blenkernel/BKE_blender_undo.h.orig
index f869790decf,ae408f2f69a..d1663a2e7f9
--- a/source/blender/blenkernel/BKE_blender_undo.h.orig
+++ b/source/blender/blenkernel/BKE_blender_undo.h.orig
@@@ -33,7 -33,7 +33,11 @@@ struct bContext
struct MemFileUndoData *BKE_memfile_undo_encode(struct Main *bmain,
struct MemFileUndoData *mfu_prev);
bool BKE_memfile_undo_decode(struct MemFileUndoData *mfu,
++<<<<<<< HEAD
+ const bool use_old_bmain_data,
++=======
+ const int undo_direction,
++>>>>>>> undo-experiments
struct bContext *C);
void BKE_memfile_undo_free(struct MemFileUndoData *mfu);
diff --cc source/blender/blenkernel/intern/blender_undo.c
index 3a91eb3c1a3,d4bdcc0ce32..83c39e81ff3
--- a/source/blender/blenkernel/intern/blender_undo.c
+++ b/source/blender/blenkernel/intern/blender_undo.c
@@@ -61,7 -61,7 +61,7 @@@
#define UNDO_DISK 0
- bool BKE_memfile_undo_decode(MemFileUndoData *mfu, const bool use_old_bmain_data, bContext *C)
-bool BKE_memfile_undo_decode(MemFileUndoData *mfu, const int undo_direction, bContext *C)
++bool BKE_memfile_undo_decode(MemFileUndoData *mfu, const int undo_direction, const bool use_old_bmain_data, bContext *C)
{
Main *bmain = CTX_data_main(C);
char mainstr[sizeof(bmain->name)];
@@@ -77,9 -77,7 +77,10 @@@
}
else {
struct BlendFileReadParams params = {0};
+ params.undo_direction = undo_direction > 0 ? 1 : -1;
+ if (!use_old_bmain_data) {
+ params.skip_flags |= BLO_READ_SKIP_UNDO_OLD_MAIN;
+ }
success = BKE_blendfile_read_from_memfile(C, &mfu->memfile, ¶ms, NULL);
}
diff --cc source/blender/blenkernel/intern/blender_undo.c.orig
index 3a91eb3c1a3,d4bdcc0ce32..eb0a93a773c
--- a/source/blender/blenkernel/intern/blender_undo.c.orig
+++ b/source/blender/blenkernel/intern/blender_undo.c.orig
@@@ -61,7 -61,7 +61,11 @@@
#define UNDO_DISK 0
++<<<<<<< HEAD
+bool BKE_memfile_undo_decode(MemFileUndoData *mfu, const bool use_old_bmain_data, bContext *C)
++=======
+ bool BKE_memfile_undo_decode(MemFileUndoData *mfu, const int undo_direction, bContext *C)
++>>>>>>> undo-experiments
{
Main *bmain = CTX_data_main(C);
char mainstr[sizeof(bmain->name)];
@@@ -77,9 -77,7 +81,13 @@@
}
else {
struct BlendFileReadParams params = {0};
++<<<<<<< HEAD
+ if (!use_old_bmain_data) {
+ params.skip_flags |= BLO_READ_SKIP_UNDO_OLD_MAIN;
+ }
++=======
+ params.undo_direction = undo_direction > 0 ? 1 : -1;
++>>>>>>> undo-experiments
success = BKE_blendfile_read_from_memfile(C, &mfu->memfile, ¶ms, NULL);
}
diff --cc source/blender/blenloader/BLO_readfile.h
index 978a38808ad,5b8cfa94520..3c6f6298bb8
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@@ -74,8 -74,11 +74,11 @@@ typedef struct WorkspaceConfigFileData
} WorkspaceConfigFileData;
struct BlendFileReadParams {
- uint skip_flags : 2; /* eBLOReadSkip */
+ uint skip_flags : 3; /* eBLOReadSkip */
uint is_startup : 1;
+
+ /** Whether we are reading the memfile for an undo (< 0) or a redo (> 0). */
+ int undo_direction : 2;
};
/* skip reading some data-block types (may want to skip screen data too). */
diff --cc source/blender/blenloader/intern/readblenentry.c
index f11d2de57c3,ce03001c5b1..dbcfee0b690
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@@ -384,16 -384,6 +384,16 @@@ BlendFileData *BLO_read_from_memfile(Ma
/* add the library pointers in oldmap lookup */
blo_add_library_pointer_map(&old_mainlist, fd);
- if ((skip_flags & BLO_READ_SKIP_UNDO_OLD_MAIN) == 0) {
++ if ((params->skip_flags & BLO_READ_SKIP_UNDO_OLD_MAIN) == 0) {
+ /* Build idmap of old main (we only care about local data here, so we can do that after
+ * split_main() call. */
+ blo_make_idmap_from_main(fd, old_mainlist.first);
+
+ /* Create sibling mapping of libmap (i.e. old ID pointer values to new valid IDs), but for
+ * the addresses from old main. */
+ blo_make_undo_reused_libmap(fd);
+ }
+
/* makes lookup of existing images in old main */
blo_make_image_pointer_map(fd, oldmain);
diff --cc source/blender/blenloader/intern/readfile.c
index 5614863be49,ff8e29ff9b5..589d4828136
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@@ -9458,12 -9444,11 +9467,15 @@@ static BHead *read_libblock(FileData *f
* and eval, not actual file reading. */
bhead = read_data_into_oldnewmap(fd, id_bhead, allocname);
+ DEBUG_PRINTF(
+ "%s: ID %s is unchanged: %d\n", __func__, id->name, fd->are_memchunks_identical);
+
- if (fd->are_memchunks_identical && !ELEM(idcode, ID_WM, ID_SCR, ID_WS)) {
- BLI_assert(fd->memfile);
+ if (fd->memfile != NULL && (fd->skip_flags & BLO_READ_SKIP_UNDO_OLD_MAIN) == 0 &&
+ fd->are_memchunks_identical && !ELEM(idcode, ID_WM, ID_SCR, ID_WS)) {
+ BLI_assert(fd->memfile != NULL);
+ BLI_assert(fd->old_idmap != NULL);
+ /* This code should only ever be reached for local data-blocks. */
+ BLI_assert(main->curlib == NULL);
/* Find the 'current' existing ID we want to reuse instead of the one we would read from
* the undo memfile. */
diff --cc source/blender/blenloader/intern/readfile.c.orig
index 5614863be49,ff8e29ff9b5..f3dc9612c1e
--- a/source/blender/blenloader/intern/readfile.c.orig
+++ b/source/blender/blenloader/intern/readfile.c.orig
@@@ -9458,12 -9444,11 +9467,20 @@@ static BHead *read_libblock(FileData *f
* and eval, not actual file reading. */
bhead = read_data_into_oldnewmap(fd, id_bhead, allocname);
++<<<<<<< HEAD
+ if (fd->memfile != NULL && (fd->skip_flags & BLO_READ_SKIP_UNDO_OLD_MAIN) == 0 &&
+ fd->are_memchunks_identical && !ELEM(idcode, ID_WM, ID_SCR, ID_WS)) {
+ BLI_assert(fd->memfile != NULL);
+ BLI_assert(fd->old_idmap != NULL);
+ /* This code should only ever be reached for local data-blocks. */
+ BLI_assert(main->curlib == NULL);
++=======
+ DEBUG_PRINTF(
+ "%s: ID %s is unchanged: %d\n", __func__, id->name, fd->are_memchunks_identical);
+
+ if (fd->are_memchunks_identical && !ELEM(idcode, ID_WM, ID_SCR, ID_WS)) {
+ BLI_assert(fd->memfile);
++>>>>>>> undo-experiments
/* Find the 'current' existing ID we want to reuse instead of the one we would read from
* the undo memfile. */
diff --cc source/blender/editors/undo/memfile_undo.c
index 2f1a9a6c8f7,15a052c7cb8..b4e1bdb3626
--- a/source/blender/editors/undo/memfile_undo.c
+++ b/source/blender/editors/undo/memfile_undo.c
@@@ -100,75 -88,16 +100,77 @@@ static bool memfile_undosys_step_encode
return true;
}
+static int memfile_undosys_step_id_reused_cb(void *user_data,
+ ID *id_self,
+ ID **id_pointer,
+ int UNUSED(cb_flag))
+{
+ BLI_assert((id_self->tag & LIB_TAG_UNDO_OLD_ID_REUSED) != 0);
+ Main *bmain = user_data;
+
+ ID *id = *id_pointer;
+ if (id != NULL && id->lib == NULL && (id->tag & LIB_TAG_UNDO_OLD_ID_REUSED) == 0) {
+ /* In case an old, re-used ID is using a newly read data-block (i.e. one of its ID pointers got
+ * updated), we have to tell the depsgraph about it. */
+ DEG_id_tag_update_ex(bmain, id_self, ID_RECALC_COPY_ON_WRITE);
+ return IDWALK_RET_STOP_ITER;
+ }
+
+ return IDWALK_RET_NOP;
+}
+
- static void memfile_undosys_step_decode(
- struct bContext *C, struct Main *bmain, UndoStep *us_p, int dir, bool UNUSED(is_final))
+ static void memfile_undosys_step_decode(struct bContext *C,
+ struct Main *bmain,
+ UndoStep *us_p,
+ int undo_direction,
+ bool UNUSED(is_final))
{
- MemFileUndoStep *us = (MemFileUndoStep *)us_p;
-
+ bool use_old_bmain_data = true;
+
- if (dir > 0) {
++ if (undo_direction > 0) {
+ /* Redo case.
+ * The only time we should have to force a complete redo is when current step is tagged as a
+ * redo barrier.
+ * If previous step was not a memfile one should not matter here, current data in old bmain
+ * should still always be valid for unchanged dtat-blocks. */
- if (us->step.use_old_bmain_data == false) {
++ if (us_p->use_old_bmain_data == false) {
+ use_old_bmain_data = false;
+ }
+ }
+ else {
+ /* Undo case.
+ * Here we do not care whether current step is an undo barrier, since we are comming from 'the
+ * future' we can still re-use old data. However, if *next* undo step (i.e. the one immédiately
+ * in the future, the one we are comming from) is a barrier, then we have to force a complete
+ * undo.
+ * Likewise, if next step (the one we are comming from) was a non-memfile one, there is no
+ * guarantee that current bmain data actually reflects the status of unchanged datablocks in
+ * memfile, since changes might have been flushed to current bmain data without triggering any
+ * memfile step storage (typical co
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list