summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclOO.c29
-rw-r--r--tests/oo.test6
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