From 55c29e36dccddc7ae8c6512b6dec074437214097 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Feb 2019 15:01:55 +1100 Subject: Undo System: add function to print undo steps Useful for debugging. --- source/blender/blenkernel/BKE_undo_system.h | 2 ++ source/blender/blenkernel/intern/undo_system.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'source/blender/blenkernel') diff --git a/source/blender/blenkernel/BKE_undo_system.h b/source/blender/blenkernel/BKE_undo_system.h index 5eac1b4f7a3..2b1c67f372b 100644 --- a/source/blender/blenkernel/BKE_undo_system.h +++ b/source/blender/blenkernel/BKE_undo_system.h @@ -200,4 +200,6 @@ void BKE_undosys_ID_map_foreach_ID_ref( struct UndoIDPtrMap *map, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data); +void BKE_undosys_print(UndoStack *ustack); + #endif /* __BKE_UNDO_SYSTEM_H__ */ diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c index 0969a3299b9..f56dd953283 100644 --- a/source/blender/blenkernel/intern/undo_system.c +++ b/source/blender/blenkernel/intern/undo_system.c @@ -1002,3 +1002,27 @@ ID *BKE_undosys_ID_map_lookup_with_prev(const UndoIDPtrMap *map, ID *id_src, ID } /** \} */ + + +/* -------------------------------------------------------------------- */ +/** \name Debug Helpers + * \{ */ + +void BKE_undosys_print(UndoStack *ustack) +{ + printf("Undo %d Steps (A: active, M=memfile-active, S=skip)\n", + BLI_listbase_count(&ustack->steps)); + int index = 0; + for (UndoStep *us = ustack->steps.first; us; us = us->next) { + printf("[%c%c%c] %3d type='%s', name='%s'\n", + (us == ustack->step_active) ? 'A' : '_', + (us == ustack->step_active_memfile) ? 'M' : '_', + us->skip ? 'S' : '_', + index, + us->type->name, + us->name); + index++; + } +} + +/** \} */ -- cgit v1.2.3