Index: generic/xotcl.c =================================================================== diff -u -rfeb8531af328828839847af665f869843c3787c2 -r8eb2c3e68f127d641d0c004332e1bd057d5654dd --- generic/xotcl.c (.../xotcl.c) (revision feb8531af328828839847af665f869843c3787c2) +++ generic/xotcl.c (.../xotcl.c) (revision 8eb2c3e68f127d641d0c004332e1bd057d5654dd) @@ -850,7 +850,7 @@ #if !defined(NDEBUG) memset(object, 0, sizeof(XOTclObject)); #endif - /*fprintf(stderr, "CKFREE obj %p\n", object);*/ + fprintf(stderr, "CKFREE obj %p\n", object); ckfree((char *) object); } } @@ -2532,7 +2532,9 @@ /* Don't do anything, if a recursive DURING_DELETE is for some * reason active. */ - /*fprintf(stderr, "CallStackDoDestroy %p flags %.6x cmd %p\n", obj, obj->flags, obj->id);*/ + /*fprintf(stderr, "CallStackDoDestroy %p %s flags %.6x cmd %p\n", + object, objectName(object), object->flags, object->id);*/ + if (object->flags & XOTCL_DURING_DELETE) { return; } @@ -12788,7 +12790,7 @@ /*fprintf(stderr,"XOTclODestroyMethod %p %s flags %.6x activation %d cmd %p cmd->flags %.6x\n", object, ((Command*)object->id)->flags == 0 ? objectName(object) : "(deleted)", - object->flags, object->activationCount, object->id, ((Command*)object->id)->flags); */ + object->flags, object->activationCount, object->id, ((Command*)object->id)->flags);*/ /* * XOTCL_DESTROY_CALLED might be set already be callDestroyMethod(), @@ -13381,8 +13383,6 @@ static int DoDealloc(Tcl_Interp *interp, XOTclObject *object) { int result; - /*object->flags |= XOTCL_DURING_DELETE;*/ - /*fprintf(stderr, "DoDealloc obj= %s %p flags %.6x activation %d cmd %p opt=%p\n", objectName(object), object, object->flags, object->activationCount, object->id, object->opt);*/ @@ -13397,6 +13397,7 @@ */ if (RUNTIME_STATE(interp)->exitHandlerDestroyRound != XOTCL_EXITHANDLER_ON_SOFT_DESTROY) { + fprintf(stderr, "DoDealloc calls CallStackDestroyObject\n"); CallStackDestroyObject(interp, object); } @@ -14414,6 +14415,7 @@ /***** SOFT DESTROY *****/ RUNTIME_STATE(interp)->exitHandlerDestroyRound = XOTCL_EXITHANDLER_ON_SOFT_DESTROY; + fprintf(stderr, "===CALL destroy on OBJECTS\n"); for (hPtr = Tcl_FirstHashEntry(commandTable, &hSrch); hPtr; hPtr = Tcl_NextHashEntry(&hSrch)) { char *key = Tcl_GetHashKey(commandTable, hPtr); @@ -14432,9 +14434,9 @@ via deleteCommandFromToken during cleanups. This could cause a destroy callback not run.... */ - RUNTIME_STATE(interp)->doFilters = 0; + //RUNTIME_STATE(interp)->doFilters = 0; - /*fprintf(stderr, "===CALL destroy on CLASSES\n");*/ + fprintf(stderr, "===CALL destroy on CLASSES\n"); for (hPtr = Tcl_FirstHashEntry(commandTable, &hSrch); hPtr; hPtr = Tcl_NextHashEntry(&hSrch)) { char *key = Tcl_GetHashKey(commandTable, hPtr); @@ -14443,7 +14445,7 @@ callDestroyMethod(interp, (XOTclObject *)cl, 0); } } - /*fprintf(stderr, "===CALL destroy on CLASSES done\n");*/ + fprintf(stderr, "===CALL destroy on CLASSES done\n"); RUNTIME_STATE(interp)->doFilters = 0; #ifdef DO_CLEANUP Index: generic/xotclStack85.c =================================================================== diff -u -ra15fb82a6c951540fdf1555473ca9a6fcae7c84c -r8eb2c3e68f127d641d0c004332e1bd057d5654dd --- generic/xotclStack85.c (.../xotclStack85.c) (revision a15fb82a6c951540fdf1555473ca9a6fcae7c84c) +++ generic/xotclStack85.c (.../xotclStack85.c) (revision 8eb2c3e68f127d641d0c004332e1bd057d5654dd) @@ -414,18 +414,22 @@ XOTCLINLINE static void CallStackPop(Tcl_Interp *interp, XOTclCallStackContent *cscPtr) { XOTclObject *object = cscPtr->self; + int allowDestroy = RUNTIME_STATE(interp)->exitHandlerDestroyRound != + XOTCL_EXITHANDLER_ON_SOFT_DESTROY; #if defined(TCL85STACK_TRACE) fprintf(stderr, "POP csc=%p, obj %s method %s\n", cscPtr, objectName(object), Tcl_GetCommandName(interp, cscPtr->cmdPtr)); #endif object->activationCount --; - /* fprintf(stderr, "decr activationCount for %s to %d cscPtr->cl %p\n", objectName(cscPtr->self), - cscPtr->self->activationCount, cscPtr->cl);*/ + /*fprintf(stderr, "decr activationCount for %s to %d cscPtr->cl %p\n", objectName(cscPtr->self), + cscPtr->self->activationCount, cscPtr->cl);*/ - if (object->activationCount < 1 && object->flags & XOTCL_DESTROY_CALLED) { + if (object->activationCount < 1 && object->flags & XOTCL_DESTROY_CALLED && allowDestroy) { CallStackDoDestroy(interp, object); + } else if (!allowDestroy) { + fprintf(stderr,"checkFree %p %s\n",object, objectName(object)); } #if 1 if (cscPtr->cl) { @@ -440,9 +444,10 @@ /*fprintf(stderr, "CallStackPop check ac %d flags %.6x\n", object->activationCount, object->flags & XOTCL_DESTROY_CALLED);*/ - if (object->activationCount < 1 && object->flags & XOTCL_DESTROY_CALLED) { - /* fprintf(stderr, "CallStackPop calls CallStackDoDestroy %p\n", object);*/ + if (object->activationCount < 1 && object->flags & XOTCL_DESTROY_CALLED && allowDestroy) { CallStackDoDestroy(interp, object); + } else if (!allowDestroy) { + fprintf(stderr,"checkFree %p %s\n",object, objectName(object)); } if (nsPtr) {