Index: trunk/src/undo.c =================================================================== --- trunk/src/undo.c (revision 9162) +++ trunk/src/undo.c (revision 9163) @@ -1668,3 +1668,29 @@ } #endif + +int undo_check(void) +{ + size_t n; + int last_serial = -2; + for(n = 0; n < UndoN; n++) { + if (last_serial != UndoList[n].Serial) { + if (last_serial > UndoList[n].Serial) { +# ifndef NDEBUG + printf("Undo broken check #1:\n"); + undo_dump(); +# endif + return 1; + } + last_serial = UndoList[n].Serial; + } + } + if (Serial < last_serial) { +# ifndef NDEBUG + printf("Undo broken check #2:\n"); + undo_dump(); +# endif + return 1; + } + return 0; +} Index: trunk/src/undo.h =================================================================== --- trunk/src/undo.h (revision 9162) +++ trunk/src/undo.h (revision 9163) @@ -105,3 +105,6 @@ } pcb_undo_op_t; #endif + +/* Returns 0 if undo integrity is not broken */ +int undo_check(void);