diff options
author | dgp <dgp@users.sourceforge.net> | 2019-05-15 19:33:53 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2019-05-15 19:33:53 (GMT) |
commit | 6b3068d9217dbc08a526a7715707192912cdb868 (patch) | |
tree | 010938b06e2f6d4a0538f8bac894fd440f434a2f /generic/tkMenu.c | |
parent | 0be716f0f282bf6e937b7ad2a8beb171b51d1659 (diff) | |
parent | 273f03adcc49bca49f4941c8adb241b5ccc26c25 (diff) | |
download | tk-6b3068d9217dbc08a526a7715707192912cdb868.zip tk-6b3068d9217dbc08a526a7715707192912cdb868.tar.gz tk-6b3068d9217dbc08a526a7715707192912cdb868.tar.bz2 |
Revised bug fix for [5d991b822e].
Diffstat (limited to 'generic/tkMenu.c')
-rw-r--r-- | generic/tkMenu.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 38e3bbd..a096684 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -2491,9 +2491,10 @@ MenuVarProc( const char *value; const char *name, *onValue; - if (flags & TCL_INTERP_DESTROYED) { + if (Tcl_InterpDeleted(interp) || (mePtr->namePtr == NULL)) { /* - * Do nothing if the interpreter is going away. + * Do nothing if the interpreter is going away or we have + * no variable name. */ return NULL; @@ -2505,17 +2506,6 @@ MenuVarProc( return NULL; } - /* - * See ticket [5d991b82]. - */ - - if (mePtr->namePtr == NULL) { - Tcl_UntraceVar2(interp, name1, name2, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - MenuVarProc, clientData); - return NULL; - } - name = Tcl_GetString(mePtr->namePtr); /* @@ -2523,12 +2513,29 @@ MenuVarProc( */ if (flags & TCL_TRACE_UNSETS) { + ClientData probe = NULL; mePtr->entryFlags &= ~ENTRY_SELECTED; - if (flags & TCL_TRACE_DESTROYED) { - Tcl_TraceVar2(interp, name, NULL, - TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - MenuVarProc, clientData); - } + + do { + probe = Tcl_VarTraceInfo(interp, name, + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + MenuVarProc, probe); + if (probe == (ClientData)mePtr) { + break; + } + } while (probe); + if (probe) { + /* + * We were able to fetch the unset trace for our + * namePtr, which means it is not unset and not + * the cause of this unset trace. Instead some outdated + * former variable must be, and we should ignore it. + */ + return NULL; + } + Tcl_TraceVar2(interp, name, NULL, + TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, + MenuVarProc, clientData); TkpConfigureMenuEntry(mePtr); TkEventuallyRedrawMenu(menuPtr, NULL); return NULL; |