summaryrefslogtreecommitdiffstats
path: root/generic/ttk
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2018-01-07 14:56:49 (GMT)
committerfvogel <fvogelnew1@free.fr>2018-01-07 14:56:49 (GMT)
commit2d0e2396eb4b66c69fb67da646de2908f5b58b01 (patch)
tree18fad73714f517993f096dd31774a28f00524d20 /generic/ttk
parent11e2b76960b0377505fdfed92ffafaa5e65c6c4d (diff)
parent3448da35684a8f1391c7750e7d0e020bf613478d (diff)
downloadtk-2d0e2396eb4b66c69fb67da646de2908f5b58b01.zip
tk-2d0e2396eb4b66c69fb67da646de2908f5b58b01.tar.gz
tk-2d0e2396eb4b66c69fb67da646de2908f5b58b01.tar.bz2
Fix [fa8de77936]: ttk::checkbutton handle empty variable graceful. Patch from Christian Werner
Diffstat (limited to 'generic/ttk')
-rw-r--r--generic/ttk/ttkButton.c19
-rw-r--r--generic/ttk/ttkProgress.c12
2 files changed, 19 insertions, 12 deletions
diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c
index c00754b..2cddb09 100644
--- a/generic/ttk/ttkButton.c
+++ b/generic/ttk/ttkButton.c
@@ -489,12 +489,15 @@ static int
CheckbuttonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
Checkbutton *checkPtr = recordPtr;
- Ttk_TraceHandle *vt = Ttk_TraceVariable(
- interp, checkPtr->checkbutton.variableObj,
- CheckbuttonVariableChanged, checkPtr);
-
- if (!vt) {
- return TCL_ERROR;
+ Tcl_Obj *varName = checkPtr->checkbutton.variableObj;
+ Ttk_TraceHandle *vt = NULL;
+
+ 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){
@@ -502,7 +505,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 4dc50a2..6c13992 100644
--- a/generic/ttk/ttkProgress.c
+++ b/generic/ttk/ttkProgress.c
@@ -421,21 +421,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);