From 07169bb2f60d244e9083a77c24fff0f964502568 Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 16 Jun 2011 20:27:22 +0000 Subject: New attempt to fix Bug 3062331 --- generic/ttk/ttkTrace.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/generic/ttk/ttkTrace.c b/generic/ttk/ttkTrace.c index 0128a1d..a469d0b 100644 --- a/generic/ttk/ttkTrace.c +++ b/generic/ttk/ttkTrace.c @@ -44,6 +44,11 @@ VarTraceProc( * If the variable is being unset, then re-establish the trace: */ if (flags & TCL_TRACE_DESTROYED) { + if (tracePtr->interp == NULL) { + Tcl_DecrRefCount(tracePtr->varnameObj); + ckfree((ClientData)tracePtr); + return NULL; + } Tcl_TraceVar(interp, name, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, VarTraceProc, clientData); @@ -104,6 +109,18 @@ Ttk_TraceHandle *Ttk_TraceVariable( void Ttk_UntraceVariable(Ttk_TraceHandle *h) { if (h) { + ClientData cd = NULL; + + while ((cd = Tcl_VarTraceInfo(h->interp, Tcl_GetString(h->varnameObj), + 0, VarTraceProc, cd)) != NULL) { + if (cd == (ClientData) h) { + break; + } + } + if (cd == NULL) { + h->interp = NULL; + return; + } Tcl_UntraceVar(h->interp, Tcl_GetString(h->varnameObj), TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, VarTraceProc, (ClientData)h); -- cgit v0.12