[Bf-blender-cvs] [547cb5e264e] master: Fix/workaround: Undo erase all dyntopo changes
Campbell Barton
noreply at git.blender.org
Fri Jan 18 14:53:34 CET 2019
Commit: 547cb5e264eb1f6b03c7327e1acae6e4f2b0187a
Author: Campbell Barton
Date: Sat Jan 19 00:48:00 2019 +1100
Branches: master
https://developer.blender.org/rB547cb5e264eb1f6b03c7327e1acae6e4f2b0187a
Fix/workaround: Undo erase all dyntopo changes
Memfile undo isn't compatible with sculpt or edit-mode.
This didn't work in 2.7x, so best disable memfile undo for now in
situations where it's going to loose data or crash.
===================================================================
M source/blender/editors/include/ED_undo.h
M source/blender/editors/undo/ed_undo.c
M source/blender/editors/undo/memfile_undo.c
===================================================================
diff --git a/source/blender/editors/include/ED_undo.h b/source/blender/editors/include/ED_undo.h
index 7995644f39e..677d64acc7d 100644
--- a/source/blender/editors/include/ED_undo.h
+++ b/source/blender/editors/include/ED_undo.h
@@ -54,6 +54,8 @@ void ED_undo_operator_repeat_cb_evt(struct bContext *C, void *arg_op, int arg
bool ED_undo_is_valid(const struct bContext *C, const char *undoname);
+bool ED_undo_is_memfile_compatible(const struct bContext *C);
+
struct UndoStack *ED_undo_stack_get(void);
/* helpers */
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index 09de2998561..337ad1d514a 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -273,6 +273,23 @@ bool ED_undo_is_valid(const bContext *C, const char *undoname)
return BKE_undosys_stack_has_undo(wm->undo_stack, undoname);
}
+bool ED_undo_is_memfile_compatible(const bContext *C)
+{
+ /* Some modes don't co-exist with memfile undo, disable their use: T60593
+ * (this matches 2.7x behavior). */
+ ViewLayer *view_layer = CTX_data_view_layer(C);
+ if (view_layer != NULL) {
+ Object *obact = OBACT(view_layer);
+ if (obact != NULL) {
+ if (obact->mode & (OB_MODE_SCULPT | OB_MODE_EDIT)) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+
/**
* Ideally we wont access the stack directly,
* this is needed for modes which handle undo themselves (bypassing #ED_undo_push).
diff --git a/source/blender/editors/undo/memfile_undo.c b/source/blender/editors/undo/memfile_undo.c
index 1560c414c42..1b0fe9a0c3d 100644
--- a/source/blender/editors/undo/memfile_undo.c
+++ b/source/blender/editors/undo/memfile_undo.c
@@ -53,13 +53,21 @@ typedef struct MemFileUndoStep {
MemFileUndoData *data;
} MemFileUndoStep;
-static bool memfile_undosys_poll(bContext *UNUSED(C))
+static bool memfile_undosys_poll(bContext *C)
{
/* other poll functions must run first, this is a catch-all. */
if ((U.uiflag & USER_GLOBALUNDO) == 0) {
return false;
}
+
+ /* Allow a single memfile undo step (the first). */
+ UndoStack *ustack = ED_undo_stack_get();
+ if ((ustack->step_active != NULL) &&
+ (ED_undo_is_memfile_compatible(C) == false))
+ {
+ return false;
+ }
return true;
}
More information about the Bf-blender-cvs
mailing list