From e5f38332d33ee51ce394b1273c7c5cb30e3994d8 Mon Sep 17 00:00:00 2001
From: Miguel Sofer <miguel.sofer@gmail.com>
Date: Thu, 20 Jun 2002 16:41:29 +0000
Subject: fix for [Bug 571385]

---
 ChangeLog          |  6 ++++++
 generic/tclBasic.c | 21 ++++++++++++---------
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cf62233..d34dac4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2002-06-20  Miguel Sofer  <msofer@users.sourceforge.net>
 
+	* generic/tclBasic.c (TclEvalObjvInternal): fix for [Bug 571385]
+	in the implementation of TIP#62 (command tracing). Vince Darley,
+	Hemang Lavana & Don Porter: thanks.
+
+2002-06-20  Miguel Sofer  <msofer@users.sourceforge.net>
+
 	* generic/tclExecute.c (TclCompEvalObj): clarified and simplified
 	the logic for compilation/recompilation.
 
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 4e73386..578b26f 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -13,7 +13,7 @@
  * See the file "license.terms" for information on usage and redistribution
  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  *
- * RCS: @(#) $Id: tclBasic.c,v 1.61 2002/06/20 00:11:43 dgp Exp $
+ * RCS: @(#) $Id: tclBasic.c,v 1.62 2002/06/20 16:41:30 msofer Exp $
  */
 
 #include "tclInt.h"
@@ -3003,7 +3003,7 @@ TclEvalObjvInternal(interp, objc, objv, command, length, flags)
     /*
      * Finally, invoke the command's Tcl_ObjCmdProc.
      */
-    
+    cmdPtr->refCount++;
     iPtr->cmdCount++;
     if ( code == TCL_OK && traceCode == TCL_OK) {
 	savedVarFramePtr = iPtr->varFramePtr;
@@ -3020,14 +3020,17 @@ TclEvalObjvInternal(interp, objc, objv, command, length, flags)
     /*
      * Call 'leave' command traces
      */
-    if ((cmdPtr->flags & CMD_HAS_EXEC_TRACES) && (traceCode == TCL_OK)) {
-	traceCode = TclCheckExecutionTraces(interp, command, length,
-		       cmdPtr, code, TCL_TRACE_LEAVE_EXEC, objc, objv);
-    }
-    if (iPtr->tracePtr != NULL && traceCode == TCL_OK) {
-	traceCode = TclCheckInterpTraces(interp, command, length,
-		       cmdPtr, code, TCL_TRACE_LEAVE_EXEC, objc, objv);
+    if (!(cmdPtr->flags & CMD_IS_DELETED)) {
+        if ((cmdPtr->flags & CMD_HAS_EXEC_TRACES) && (traceCode == TCL_OK)) {
+            traceCode = TclCheckExecutionTraces (interp, command, length,
+                   cmdPtr, code, TCL_TRACE_LEAVE_EXEC, objc, objv);
+        }
+        if (iPtr->tracePtr != NULL && traceCode == TCL_OK) {
+            traceCode = TclCheckInterpTraces(interp, command, length,
+                   cmdPtr, code, TCL_TRACE_LEAVE_EXEC, objc, objv);
+        }
     }
+    TclCleanupCommand(cmdPtr);
 
     /*
      * If one of the trace invocation resulted in error, then 
-- 
cgit v0.12