| Ticket UUID: | fa8de779361f5ec2a0464f380c49e499d50925fa | |||
| Title: | ttk::checkbutton handle empty variable graceful | |||
| Type: | Bug | Version: | 8.6.5 | |
| Submitter: | chw | Created on: | 2016-05-09 05:50:43 | |
| Subsystem: | 88. Themed Tk | Assigned To: | fvogel | |
| Priority: | 5 Medium | Severity: | Important | |
| Status: | Closed | Last Modified: | 2018-01-07 15:20:44 | |
| Resolution: | Fixed | Closed By: | fvogel | |
| Closed on: | 2018-01-07 15:20:44 | |||
| Description: |
ttk::checkbutton can cause a crash of Tk when given no variable to be traced. This seems to be caused by missing tests in CheckbuttonConfigure(). The following patch in AndroWish derived from similar code in ttk::progressbar fixes this: http://www.androwish.org/index.html/vpatch?from=db93e67e3e8e382e&to=37fdd0e1ce98eb1a | |||
| User Comments: |
fvogel added on 2018-01-07 15:20:44:
Merged to core-8-6-branch and trunk. Thanks Christian! chw added on 2018-01-07 14:38:31: Oh no, I get a core dump, too. Bummer. This should fix it by proper handling the no variable case in the command invoke function and calling directly the state change function.
Index: tk/generic/ttk/ttkButton.c
==================================================================
--- tk/generic/ttk/ttkButton.c
+++ tk/generic/ttk/ttkButton.c
@@ -553,14 +553,17 @@
if (corePtr->state & TTK_STATE_SELECTED)
newValue = checkPtr->checkbutton.offValueObj;
else
newValue = checkPtr->checkbutton.onValueObj;
- if (Tcl_ObjSetVar2(interp,
- checkPtr->checkbutton.variableObj, NULL, newValue,
- TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG)
- == NULL)
+ if (checkPtr->checkbutton.variableObj == NULL ||
+ *Tcl_GetString(checkPtr->checkbutton.variableObj) == '\0')
+ CheckbuttonVariableChanged(checkPtr, Tcl_GetString(newValue));
+ else if (Tcl_ObjSetVar2(interp,
+ checkPtr->checkbutton.variableObj, NULL, newValue,
+ TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG)
+ == NULL)
return TCL_ERROR;
if (WidgetDestroyed(corePtr))
return TCL_ERROR;
fvogel added on 2018-01-07 14:36:33: The TK_OPTION_NULL_OK change from [9d6cd6ae] was already in core-8-6-branch and trunk, but not the ttkButton.c complementary changes from [a5d4c359]. As a consequence the problem was not in Andowish only, it crashed in core-8-6-branch and trunk. Ticket priority raised because of this. I have applied the patch from Christian Werner in branch bug-fa8de77936. The first commit fixes this issue. The second commit is unrelated to the present issue but I have nevertheless committed it in the same branch because it was provided by Christian along with the first fix as a single commit in Androwish. This approach gives some consistency with what was done in Androwish. Test checkbutton-1.8 added to guard against regressions. stu added on 2018-01-07 13:02:39: I get a core dump with:
ttk::checkbutton .x -variable {}
Needs the TK_OPTION_NULL_OK change from [9d6cd6ae] and the ttkButton.c changes from [a5d4c359].
jan.nijtmans added on 2016-05-09 12:11:59: Thanks, Christian, for the clarification! This means the ticket is no longer Critical, just Cosmetic. I'll leave the further handling of this ticket to Joe. chw added on 2016-05-09 11:58:26: Sorry for the noise. Problem was introduced by using TK_OPTION_NULL_OK in ttkButton.c in AndroWish only, not in Tk:
{TK_OPTION_STRING, "-variable", "variable", "Variable",
NULL, Tk_Offset(Checkbutton, checkbutton.variableObj), -1,
TK_OPTION_NULL_OK,0,0},
The reason for TK_OPTION_NULL_OK was to make ttk::checkbutton behave exactly like a normal Tk checkbutton w.r.t. the -variable option.
Maybe this should be considered for mainline Tk, too.
jan.nijtmans added on 2016-05-09 09:37:21: Suggested fix committed to androwish branch [a5d4c359662e28b6], ready to be cherry-picked to whatever other branch. Joe, please review. | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki