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:
Diffstat (limited to 'source/blender/editors/undo/ed_undo.c')
-rw-r--r--source/blender/editors/undo/ed_undo.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index 6d5f486ebe9..582a2ccaef7 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -322,6 +322,39 @@ bool ED_undo_is_memfile_compatible(const bContext *C)
}
/**
+ * When a property of ID changes, return false.
+ *
+ * This is to avoid changes to a property making undo pushes
+ * which are ignored by the undo-system.
+ * For example, changing a brush property isn't stored by sculpt-mode undo steps.
+ * This workaround is needed until the limitation is removed, see: T61948.
+ */
+bool ED_undo_is_legacy_compatible_for_property(struct bContext *C, ID *id)
+{
+ 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_ALL_PAINT) {
+ /* Don't store property changes when painting
+ * (only do undo pushes on brush strokes which each paint operator handles on it's own). */
+ CLOG_INFO(&LOG, 1, "skipping undo for paint-mode");
+ return false;
+ }
+ else if (obact->mode & OB_MODE_EDIT) {
+ if ((id == NULL) || (obact->data == NULL) ||
+ (GS(id->name) != GS(((ID *)obact->data)->name))) {
+ /* No undo push on id type mismatch in edit-mode. */
+ CLOG_INFO(&LOG, 1, "skipping undo for edit-mode");
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+}
+
+/**
* Ideally we wont access the stack directly,
* this is needed for modes which handle undo themselves (bypassing #ED_undo_push).
*