Index: trunk/src/libcschem/cnc_grp.c =================================================================== --- trunk/src/libcschem/cnc_grp.c (revision 1243) +++ trunk/src/libcschem/cnc_grp.c (revision 1244) @@ -328,6 +328,11 @@ } } +static void cgrp_remove_alloc(csch_undo_remove_t *slot) +{ + +} + static void cgrp_remove_redo(csch_undo_remove_t *slot) { csch_rtree_remove_recursive(slot->sheet, slot->obj); /* need to manually remove from retree because children are also added */ @@ -356,7 +361,7 @@ const csch_ops_t csch_ops_cgrp_ref = { - NULL, cgrp_remove_redo, cgrp_remove_undo, + NULL, cgrp_remove_alloc, cgrp_remove_redo, cgrp_remove_undo, cgrp_isc_with_box }; Index: trunk/src/libcschem/cnc_line.c =================================================================== --- trunk/src/libcschem/cnc_line.c (revision 1243) +++ trunk/src/libcschem/cnc_line.c (revision 1244) @@ -108,7 +108,11 @@ return &line->hdr; } +static void line_remove_alloc(csch_undo_remove_t *slot) +{ +} + static void line_remove_redo(csch_undo_remove_t *slot) { csch_cnc_common_remove_redo(slot, CSCH_REM_FROM_RTREE | CSCH_REM_FROM_PARENT | CSCH_REM_DEL_EMPTY_PARENT); @@ -149,7 +153,7 @@ } const csch_ops_t csch_ops_line = { - line_create, line_remove_redo, line_remove_undo, + line_create, line_remove_alloc, line_remove_redo, line_remove_undo, line_isc_with_box }; Index: trunk/src/libcschem/operation.c =================================================================== --- trunk/src/libcschem/operation.c (revision 1243) +++ trunk/src/libcschem/operation.c (revision 1244) @@ -76,7 +76,14 @@ u->obj = obj; u->sheet = sheet; + uundo_freeze_serial(&sheet->undo); /* remove_alloc() may have side effects: undoable changes to other related objects; bundle them */ + ops->remove_alloc(u); + uundo_unfreeze_serial(&sheet->undo); + ops->remove_redo(u); + + if (how & CSCH_REM_UNDOABLE) + csch_undo_inc_serial(sheet); return obj; } Index: trunk/src/libcschem/operation.h =================================================================== --- trunk/src/libcschem/operation.h (revision 1243) +++ trunk/src/libcschem/operation.h (revision 1244) @@ -37,6 +37,7 @@ typedef struct { csch_chdr_t *(*create)(csch_sheet_t *sheet, csch_cgrp_t *parent); + void (*remove_alloc)(csch_undo_remove_t *slot); void (*remove_redo)(csch_undo_remove_t *slot); void (*remove_undo)(csch_undo_remove_t *slot); int (*isc_with_box)(csch_chdr_t *obj, csch_rtree_box_t *box); Index: trunk/src/libcschem/undo.c =================================================================== --- trunk/src/libcschem/undo.c (revision 1243) +++ trunk/src/libcschem/undo.c (revision 1244) @@ -124,3 +124,9 @@ rnd_event(&sheet->hidlib, CSCH_EVENT_UNDO_POST, "i", CSCH_UNDO_EV_CLEAR_LIST); } } + +void csch_undo_inc_serial(csch_sheet_t *sheet) +{ + uundo_inc_serial(&sheet->undo); + rnd_event(&sheet->hidlib, CSCH_EVENT_UNDO_POST, "i", CSCH_UNDO_EV_REDO); +} Index: trunk/src/libcschem/undo.h =================================================================== --- trunk/src/libcschem/undo.h (revision 1243) +++ trunk/src/libcschem/undo.h (revision 1244) @@ -39,5 +39,6 @@ int csch_undo(csch_sheet_t *sheet); int csch_redo(csch_sheet_t *sheet); void csch_undo_clear_list(csch_sheet_t *sheet, rnd_bool Force); +void csch_undo_inc_serial(csch_sheet_t *sheet); #endif