From 6721be522c279e1343d675072819bd1671b40fe8 Mon Sep 17 00:00:00 2001 From: dgp Date: Sat, 11 May 2019 20:53:22 +0000 Subject: Fix for the [button ... -textvariable] parts of [5d991b822e]. --- generic/tkButton.c | 29 ++++++++++++++++++++++++++++- tests/button.test | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/generic/tkButton.c b/generic/tkButton.c index b7e314e..0e1a4e9 100644 --- a/generic/tkButton.c +++ b/generic/tkButton.c @@ -1709,7 +1709,34 @@ ButtonTextVarProc( */ if (flags & TCL_TRACE_UNSETS) { - if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) { + if (!Tcl_InterpDeleted(interp) && butPtr->textVarNamePtr != NULL) { + + /* + * An unset trace on some variable brought us here, but is it + * the variable we have stored in butPtr->textVarNamePtr ? + */ + + ClientData probe = NULL; + + do { + probe = Tcl_VarTraceInfo(interp, + Tcl_GetString(butPtr->textVarNamePtr), + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + ButtonTextVarProc, probe); + if (probe == (ClientData)butPtr) { + break; + } + } while (probe); + if (probe) { + /* + * We were able to fetch the unset trace for our + * textVarNamePtr, which means it is not unset and not + * the cause of this unset trace. Instead some outdated + * former textvariable must be, and we should ignore it. + */ + return NULL; + } + Tcl_ObjSetVar2(interp, butPtr->textVarNamePtr, NULL, butPtr->textPtr, TCL_GLOBAL_ONLY); Tcl_TraceVar2(interp, Tcl_GetString(butPtr->textVarNamePtr), diff --git a/tests/button.test b/tests/button.test index 21ccf8f..edc5a42 100644 --- a/tests/button.test +++ b/tests/button.test @@ -3978,7 +3978,7 @@ test button-15.2 {Bug [5d991b822e]} { .b configure -textvariable new }}} pack .b - bind .b {unset var} + bind .b {unset -nocomplain var} update destroy .b unset new -- cgit v0.12