diff options
author | dgp <dgp@users.sourceforge.net> | 2006-06-14 22:15:17 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2006-06-14 22:15:17 (GMT) |
commit | 435e02ea268c7298e0ca532f5bb78c990886abd2 (patch) | |
tree | df0b8f2cba26be1a1f3e87e6b52a49cb79f842ab /generic/tkScale.c | |
parent | 8c9c2515b6c3ff39cf095d04bbcb0e2192d9ac41 (diff) | |
download | tk-435e02ea268c7298e0ca532f5bb78c990886abd2.zip tk-435e02ea268c7298e0ca532f5bb78c990886abd2.tar.gz tk-435e02ea268c7298e0ca532f5bb78c990886abd2.tar.bz2 |
* generic/tkScale.c: Revised variable writing logic to account
for [scale]'s design that it deals with its value as a formatted
string, and not as a double. [Bug 891141].
Diffstat (limited to 'generic/tkScale.c')
-rw-r--r-- | generic/tkScale.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/generic/tkScale.c b/generic/tkScale.c index 9741fde..c392a6d 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -18,7 +18,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkScale.c,v 1.17 2002/08/05 04:30:40 dgp Exp $ + * RCS: @(#) $Id: tkScale.c,v 1.17.2.1 2006/06/14 22:15:22 dgp Exp $ */ #include "tkPort.h" @@ -580,7 +580,7 @@ ConfigureScale(interp, scalePtr, objc, objv) Tk_SavedOptions savedOptions; Tcl_Obj *errorResult = NULL; int error; - double oldValue = scalePtr->value; + double varValue; /* * Eliminate any existing trace on a variable monitored by the scale. @@ -690,10 +690,17 @@ ConfigureScale(interp, scalePtr, objc, objv) */ valuePtr = Tcl_ObjGetVar2(interp, scalePtr->varNamePtr, NULL, TCL_GLOBAL_ONLY); - if ((valuePtr == NULL) || (scalePtr->value != oldValue) - || (Tcl_GetDoubleFromObj(NULL, valuePtr, &oldValue) != TCL_OK) - || (scalePtr->value != oldValue)) { + if ((valuePtr == NULL) || (Tcl_GetDoubleFromObj(NULL, + valuePtr, &varValue) != TCL_OK)) { ScaleSetVariable(scalePtr); + } else { + char varString[TCL_DOUBLE_SPACE]; + char scaleString[TCL_DOUBLE_SPACE]; + sprintf(varString, scalePtr->format, varValue); + sprintf(scaleString, scalePtr->format, scalePtr->value); + if (strcmp(varString, scaleString)) { + ScaleSetVariable(scalePtr); + } } Tcl_TraceVar(interp, Tcl_GetString(scalePtr->varNamePtr), TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, |