diff options
author | dgp <dgp@users.sourceforge.net> | 2015-12-22 19:50:04 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2015-12-22 19:50:04 (GMT) |
commit | 2516cd875a00dd9b9f1d23f43a86342c1007bdb4 (patch) | |
tree | 6fe976dda1efa57c1d8bee8150a2c4c73a53bc66 | |
parent | 1614457e38312b8180cd9ef843bffcc6a45a14cc (diff) | |
download | tcl-2516cd875a00dd9b9f1d23f43a86342c1007bdb4.zip tcl-2516cd875a00dd9b9f1d23f43a86342c1007bdb4.tar.gz tcl-2516cd875a00dd9b9f1d23f43a86342c1007bdb4.tar.bz2 |
[593baa032c] Additional fix for the mixinSubs list.
-rw-r--r-- | generic/tclOO.c | 29 | ||||
-rw-r--r-- | tests/oo.test | 6 |
2 files changed, 27 insertions, 8 deletions
diff --git a/generic/tclOO.c b/generic/tclOO.c index f2e0ca9..34eb5ad 100644 --- a/generic/tclOO.c +++ b/generic/tclOO.c @@ -58,6 +58,7 @@ static const struct { static Class * AllocClass(Tcl_Interp *interp, Object *useThisObj); static Object * AllocObject(Tcl_Interp *interp, const char *nameStr, const char *nsNameStr); +static void ClearMixins(Class *clsPtr); static void ClearSuperclasses(Class *clsPtr); static int CloneClassMethod(Tcl_Interp *interp, Class *clsPtr, Method *mPtr, Tcl_Obj *namePtr, @@ -906,6 +907,20 @@ ObjectRenamedTrace( */ static void +ClearMixins( + Class *clsPtr) +{ + int i; + Class *mixinPtr; + + FOREACH(mixinPtr, clsPtr->mixins) { + TclOORemoveFromMixinSubs(clsPtr, mixinPtr); + } + ckfree(clsPtr->mixins.list); + clsPtr->mixins.num = 0; +} + +static void ClearSuperclasses( Class *clsPtr) { @@ -994,6 +1009,9 @@ ReleaseClassContents( Tcl_DeleteCommandFromToken(interp, mixinSubclassPtr->thisPtr->command); } + if (mixinSubclassPtr->mixins.num) { + ClearMixins(mixinSubclassPtr); + } DelRef(mixinSubclassPtr->thisPtr); DelRef(mixinSubclassPtr); } @@ -1232,14 +1250,9 @@ ObjectNamespaceDeleted( ckfree(clsPtr->filters.list); clsPtr->filters.num = 0; } - FOREACH(mixinPtr, clsPtr->mixins) { - if (!Deleted(mixinPtr->thisPtr)) { - TclOORemoveFromMixinSubs(clsPtr, mixinPtr); - } - } - if (i) { - ckfree(clsPtr->mixins.list); - clsPtr->mixins.num = 0; + + if (clsPtr->mixins.num) { + ClearMixins(clsPtr); } if (clsPtr->superclasses.num) { ClearSuperclasses(clsPtr); diff --git a/tests/oo.test b/tests/oo.test index ca5c7f9..895f7ed 100644 --- a/tests/oo.test +++ b/tests/oo.test @@ -3677,6 +3677,12 @@ test oo-35.3 {Bug 593baa032c: superclass list teardown} { oo::class create D {superclass B} namespace eval [info object namespace D] [list [namespace which B] destroy] } {} +test oo-35.4 {Bug 593baa032c: mixins list teardown} { + # Bug makes this crash, especially with mem-debugging on + oo::class create B {} + oo::class create D {mixin B} + namespace eval [info object namespace D] [list [namespace which B] destroy] +} {} cleanupTests |