summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <jan.nijtmans@noemail.net>2016-05-09 09:35:14 (GMT)
committerjan.nijtmans <jan.nijtmans@noemail.net>2016-05-09 09:35:14 (GMT)
commit5cd449fd45fcc8e4295f172f016a8e10cb10c54e (patch)
tree36f65cf4995c34e70cb40078b6f2906b1b3d3ed3
parent37b4fd6a24ddd4a455cde329b6e5d8de22eb1674 (diff)
downloadtk-bug-fa8de779361f5ec2.zip
tk-bug-fa8de779361f5ec2.tar.gz
tk-bug-fa8de779361f5ec2.tar.bz2
Fix [fa8de779361f5ec2]: ttk::checkbutton handle empty variable graceful. A test-case would be nice.bug-fa8de779361f5ec2
FossilOrigin-Name: a5d4c359662e28b67599c110af5a9242dac16128
-rw-r--r--generic/ttk/ttkButton.c15
-rw-r--r--generic/ttk/ttkProgress.c12
2 files changed, 16 insertions, 11 deletions
diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c
index bc44f25..9067f71 100644
--- a/generic/ttk/ttkButton.c
+++ b/generic/ttk/ttkButton.c
@@ -480,12 +480,13 @@ static int
CheckbuttonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
Checkbutton *checkPtr = recordPtr;
- Ttk_TraceHandle *vt = Ttk_TraceVariable(
- interp, checkPtr->checkbutton.variableObj,
- CheckbuttonVariableChanged, checkPtr);
+ Tcl_Obj *varName = checkPtr->checkbutton.variableObj;
+ Ttk_TraceHandle *vt = 0;
- if (!vt) {
- return TCL_ERROR;
+ if (varName != NULL && *Tcl_GetString(varName) != '\0') {
+ vt = Ttk_TraceVariable(interp, varName,
+ CheckbuttonVariableChanged, checkPtr);
+ if (!vt) return TCL_ERROR;
}
if (BaseConfigure(interp, recordPtr, mask) != TCL_OK){
@@ -493,7 +494,9 @@ CheckbuttonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
return TCL_ERROR;
}
- Ttk_UntraceVariable(checkPtr->checkbutton.variableTrace);
+ if (checkPtr->checkbutton.variableTrace) {
+ Ttk_UntraceVariable(checkPtr->checkbutton.variableTrace);
+ }
checkPtr->checkbutton.variableTrace = vt;
return TCL_OK;
diff --git a/generic/ttk/ttkProgress.c b/generic/ttk/ttkProgress.c
index 47e44d8..a5e814a 100644
--- a/generic/ttk/ttkProgress.c
+++ b/generic/ttk/ttkProgress.c
@@ -425,21 +425,23 @@ static int ProgressbarStepCommand(
}
newValueObj = Tcl_NewDoubleObj(value);
+ Tcl_IncrRefCount(newValueObj);
TtkRedisplayWidget(&pb->core);
/* Update value by setting the linked -variable, if there is one:
*/
if (pb->progress.variableTrace) {
- return Tcl_ObjSetVar2(
- interp, pb->progress.variableObj, 0, newValueObj,
- TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)
- ? TCL_OK : TCL_ERROR;
+ int result = Tcl_ObjSetVar2(
+ interp, pb->progress.variableObj, 0, newValueObj,
+ TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)
+ ? TCL_OK : TCL_ERROR;
+ Tcl_DecrRefCount(newValueObj);
+ return result;
}
/* Otherwise, change the -value directly:
*/
- Tcl_IncrRefCount(newValueObj);
Tcl_DecrRefCount(pb->progress.valueObj);
pb->progress.valueObj = newValueObj;
CheckAnimation(pb);