diff --git a/source/blender/editors/include/ED_undo.hh b/source/blender/editors/include/ED_undo.hh index d291248cc07..6cac085aa88 100644 --- a/source/blender/editors/include/ED_undo.hh +++ b/source/blender/editors/include/ED_undo.hh @@ -15,6 +15,7 @@ struct Base; struct CLG_LogRef; struct ID; struct MemFile; +struct PointerRNA; struct Object; struct Scene; struct UndoStack; @@ -72,7 +73,7 @@ bool ED_undo_is_memfile_compatible(const bContext *C); * For example, changing a brush property isn't stored by sculpt-mode undo steps. * This workaround is needed until the limitation is removed, see: #61948. */ -bool ED_undo_is_legacy_compatible_for_property(bContext *C, ID *id); +bool ED_undo_is_legacy_compatible_for_property(bContext *C, ID *id, PointerRNA &ptr); /** * This function addresses the problem of restoring undo steps when multiple windows are used. diff --git a/source/blender/editors/interface/interface_handlers.cc b/source/blender/editors/interface/interface_handlers.cc index 5753bc5eb9b..332b663a9fe 100644 --- a/source/blender/editors/interface/interface_handlers.cc +++ b/source/blender/editors/interface/interface_handlers.cc @@ -1012,8 +1012,8 @@ static void ui_apply_but_undo(uiBut *but) } else { ID *id = but->rnapoin.owner_id; - if (!ED_undo_is_legacy_compatible_for_property(static_cast(but->block->evil_C), - id)) + if (!ED_undo_is_legacy_compatible_for_property( + static_cast(but->block->evil_C), id, but->rnapoin)) { skip_undo = true; } diff --git a/source/blender/editors/undo/ed_undo.cc b/source/blender/editors/undo/ed_undo.cc index ef7bcfecf34..5dc324862bf 100644 --- a/source/blender/editors/undo/ed_undo.cc +++ b/source/blender/editors/undo/ed_undo.cc @@ -419,8 +419,16 @@ bool ED_undo_is_memfile_compatible(const bContext *C) return true; } -bool ED_undo_is_legacy_compatible_for_property(bContext *C, ID *id) +bool ED_undo_is_legacy_compatible_for_property(bContext *C, ID *id, PointerRNA &ptr) { + if (!RNA_struct_undo_check(ptr.type)) { + return false; + } + /* If the whole ID type doesn't support undo there is no need to check the current context. */ + if (id && !ID_CHECK_UNDO(id)) { + return false; + } + const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); if (view_layer != nullptr) { diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 90af581fbcf..bc538672a2f 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -605,7 +605,8 @@ typedef struct PreviewImage { #define ID_REFCOUNTING_USERS(id) (ID_REAL_USERS(id) - ID_EXTRA_REAL_USERS(id)) #define ID_CHECK_UNDO(id) \ - ((GS((id)->name) != ID_SCR) && (GS((id)->name) != ID_WM) && (GS((id)->name) != ID_WS)) + ((GS((id)->name) != ID_SCR) && (GS((id)->name) != ID_WM) && (GS((id)->name) != ID_WS)) && \ + (GS((id)->name) != ID_BR) #define ID_BLEND_PATH(_bmain, _id) \ ((_id)->lib ? (_id)->lib->runtime->filepath_abs : BKE_main_blendfile_path((_bmain))) diff --git a/source/blender/windowmanager/intern/wm_operators.cc b/source/blender/windowmanager/intern/wm_operators.cc index 6f0cf9d386a..cb3a67f0973 100644 --- a/source/blender/windowmanager/intern/wm_operators.cc +++ b/source/blender/windowmanager/intern/wm_operators.cc @@ -3441,7 +3441,7 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even wmWindowManager *wm = CTX_wm_manager(C); if (wm->op_undo_depth == 0) { ID *id = rc->ptr.owner_id; - if (ED_undo_is_legacy_compatible_for_property(C, id)) { + if (ED_undo_is_legacy_compatible_for_property(C, id, rc->ptr)) { ED_undo_push(C, op->type->name); } }