summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjenglish@flightlab.com <jenglish>2016-01-25 20:48:08 (GMT)
committerjenglish@flightlab.com <jenglish>2016-01-25 20:48:08 (GMT)
commit2bad5d12b19e2c67fcaeb064c3a8b366cb06a61f (patch)
treee286c00ee2dc370f177d3a081510dbbde55af4c2
parent05e2c7c9330385c357b0edc8c684f93d281dc3c4 (diff)
downloadtk-2bad5d12b19e2c67fcaeb064c3a8b366cb06a61f.zip
tk-2bad5d12b19e2c67fcaeb064c3a8b366cb06a61f.tar.gz
tk-2bad5d12b19e2c67fcaeb064c3a8b366cb06a61f.tar.bz2
NotebookAddCommand: fix off-by-one error counting objc/objv
when readding an already-managed window with arguments. Bug reported on tcl-core by Sam Bromley (22 Jan 2016)
-rw-r--r--generic/ttk/ttkNotebook.c2
-rw-r--r--tests/ttk/notebook.test21
2 files changed, 22 insertions, 1 deletions
diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c
index 16a8bfe..81a8b64 100644
--- a/generic/ttk/ttkNotebook.c
+++ b/generic/ttk/ttkNotebook.c
@@ -901,7 +901,7 @@ static int NotebookAddCommand(
if (tab->state == TAB_STATE_HIDDEN) {
tab->state = TAB_STATE_NORMAL;
}
- if (ConfigureTab(interp, nb, tab, slaveWindow, objc-4,objv+4) != TCL_OK) {
+ if (ConfigureTab(interp, nb, tab, slaveWindow, objc-3,objv+3) != TCL_OK) {
return TCL_ERROR;
}
diff --git a/tests/ttk/notebook.test b/tests/ttk/notebook.test
index cdce020..3a2a6ff 100644
--- a/tests/ttk/notebook.test
+++ b/tests/ttk/notebook.test
@@ -468,6 +468,27 @@ test notebook-1817596-3 "insert/configure" -body {
} -result [list [list .nb.l2 .nb.l0 .nb.l1] L2 L0 L1] -cleanup { destroy .nb }
+test notebook-readd-1 "add same widget twice" -body {
+ pack [ttk::notebook .nb]
+ .nb add [ttk::button .nb.b1] -text "Button"
+ .nb add .nb.b1
+ .nb tabs
+} -result [list .nb.b1] -cleanup { destroy .nb }
+
+test notebook-readd-2 "add same widget twice, with options" -body {
+ pack [ttk::notebook .nb]
+ .nb add [ttk::button .nb.b1] -text "Tab label"
+ .nb add .nb.b1 -text "Changed tab label"
+ .nb tabs
+} -result [list .nb.b1] -cleanup { destroy .nb }
+
+test notebook-readd-3 "insert same widget twice, with options" -body {
+ pack [ttk::notebook .nb]
+ .nb insert end [ttk::button .nb.b1] -text "Tab label"
+ .nb insert end .nb.b1 -text "Changed tab label"
+ .nb tabs
+} -result [list .nb.b1] -cleanup { destroy .nb }
+
# See #1343984
test notebook-1343984-1 "don't autoselect on destroy - setup" -body {