From 81f1e32f9fc5bd5badc575ff2410440382e87181 Mon Sep 17 00:00:00 2001 From: a_kovalenko Date: Thu, 12 Jan 2006 23:29:35 +0000 Subject: generic/tkUndo.c (TkUndoSetDepth): Don't free TkUndoSubAtoms for separator entries that are deleted: there is some unpredictable garbage instead of subatoms. Free both 'apply' and 'revert' action chains for non-separator entries. --- ChangeLog | 9 +++++++++ generic/tkUndo.c | 32 +++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 75813aa..d26e6da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-01-13 Anton Kovalenko + + * generic/tkUndo.c (TkUndoSetDepth): Don't free + TkUndoSubAtoms for separator entries that are deleted: + there is some unpredictable garbage instead of subatoms. + + Free both 'apply' and 'revert' action chains for + non-separator entries. + 2006-01-12 Donal K. Fellows TIP #260 IMPLEMENTATION diff --git a/generic/tkUndo.c b/generic/tkUndo.c index db6a5a8..27a31ce 100644 --- a/generic/tkUndo.c +++ b/generic/tkUndo.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUndo.c,v 1.9 2005/12/28 17:26:22 dkf Exp $ + * RCS: @(#) $Id: tkUndo.c,v 1.10 2006/01/12 23:29:36 a_kovalenko Exp $ */ #include "tkUndo.h" @@ -395,19 +395,29 @@ TkUndoSetDepth( } prevelem->next = NULL; while (elem != NULL) { - TkUndoSubAtom *sub = elem->apply; prevelem = elem; - - while (sub->next != NULL) { - TkUndoSubAtom *next = sub->next; - - if (sub->action != NULL) { - Tcl_DecrRefCount(sub->action); + if (elem->type != TK_UNDO_SEPARATOR) { + TkUndoSubAtom *sub = elem->apply; + while (sub->next != NULL) { + TkUndoSubAtom *next = sub->next; + + if (sub->action != NULL) { + Tcl_DecrRefCount(sub->action); + } + ckfree((char *)sub); + sub = next; + } + sub = elem->revert; + while (sub->next != NULL) { + TkUndoSubAtom *next = sub->next; + + if (sub->action != NULL) { + Tcl_DecrRefCount(sub->action); + } + ckfree((char *)sub); + sub = next; } - ckfree((char *)sub); - sub = next; } - elem = elem->next; ckfree((char *) prevelem); } -- cgit v0.12