Undo System: add function to print undo steps

Useful for debugging.
This commit is contained in:
2019-02-04 15:01:55 +11:00
parent b5c841498c
commit 55c29e36dc
3 changed files with 33 additions and 0 deletions

View File

@@ -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__ */

View File

@@ -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++;
}
}
/** \} */

View File

@@ -66,6 +66,7 @@ const EnumPropertyItem rna_enum_window_cursor_items[] = {
#ifdef RNA_RUNTIME
#include "BKE_context.h"
#include "BKE_undo_system.h"
#include "WM_types.h"
@@ -457,6 +458,11 @@ static void rna_PieMenuEnd(bContext *C, PointerRNA *handle)
UI_pie_menu_end(C, handle->data);
}
static void rna_WindowManager_print_undo_steps(wmWindowManager *wm)
{
BKE_undosys_print(wm->undo_stack);
}
static PointerRNA rna_WindoManager_operator_properties_last(const char *idname)
{
wmOperatorType *ot = WM_operatortype_find(idname, true);
@@ -783,6 +789,7 @@ void RNA_api_wm(StructRNA *srna)
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_RNAPTR);
RNA_def_function_return(func, parm);
RNA_def_function(srna, "print_undo_steps", "rna_WindowManager_print_undo_steps");
}
void RNA_api_operator(StructRNA *srna)