diff --git a/database/DBundo.c b/database/DBundo.c index 255c3af8..84c9a172 100644 --- a/database/DBundo.c +++ b/database/DBundo.c @@ -788,9 +788,11 @@ dbUndoCellBack(up) break; case UNDO_CELL_PLACE: use = findUse(up, TRUE); - DBUnLinkCell(use, up->cue_parent); - DBDeleteCell(use); - (void) DBCellDeleteUse(use); + if(use) { + DBUnLinkCell(use, up->cue_parent); + DBDeleteCell(use); + (void) DBCellDeleteUse(use); + } DBReComputeBbox(up->cue_parent); DBWAreaChanged(up->cue_parent, &up->cue_bbox, DBW_ALLWINDOWS, (TileTypeBitMask *) NULL); @@ -804,9 +806,11 @@ dbUndoCellBack(up) */ case UNDO_CELL_CLRID: use = findUse(up, FALSE); /* Find it with a NULL id */ - (void) DBReLinkCell(use, up->cue_id); - DBWAreaChanged(up->cue_parent, &up->cue_bbox, - (int) ~use->cu_expandMask, &DBAllButSpaceBits); + if(use) { + (void) DBReLinkCell(use, up->cue_id); + DBWAreaChanged(up->cue_parent, &up->cue_bbox, + (int) ~use->cu_expandMask, &DBAllButSpaceBits); + } break; /* * The following is a hack. @@ -817,16 +821,20 @@ dbUndoCellBack(up) */ case UNDO_CELL_SETID: use = findUse(up, TRUE); /* Find it with current id */ - DBUnLinkCell(use, up->cue_parent); - freeMagic(use->cu_id); - use->cu_id = (char *) NULL; + if(use) { + DBUnLinkCell(use, up->cue_parent); + freeMagic(use->cu_id); + use->cu_id = (char *) NULL; + } break; case UNDO_CELL_LOCKDOWN: use = findUse(up, TRUE); - use->cu_flags = up->cue_flags; - DBWAreaChanged(up->cue_parent, &up->cue_bbox, + if(use) { + use->cu_flags = up->cue_flags; + DBWAreaChanged(up->cue_parent, &up->cue_bbox, (int) ~use->cu_expandMask, &DBAllButSpaceBits); + } break; } }