summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjenglish <jenglish@flightlab.com>2010-10-11 21:35:27 (GMT)
committerjenglish <jenglish@flightlab.com>2010-10-11 21:35:27 (GMT)
commit77bf3ab590b4d2db7dfef2295444b5ef0f0d6723 (patch)
tree1ed7927ca375d0f312bc0e5a8667669b4aba4199
parent83e899ada1765ac80098a4c4cd80d0a8e0b04da0 (diff)
downloadtk-77bf3ab590b4d2db7dfef2295444b5ef0f0d6723.zip
tk-77bf3ab590b4d2db7dfef2295444b5ef0f0d6723.tar.gz
tk-77bf3ab590b4d2db7dfef2295444b5ef0f0d6723.tar.bz2
Fix crash in 'tag add' / 'tag remove' when no -tags specified [SF#3085489].
-rw-r--r--ChangeLog5
-rw-r--r--generic/ttk/ttkTreeview.c8
-rw-r--r--tests/ttk/treeview.test24
3 files changed, 31 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 73973d6..e3f4dc4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-10-11 Joe English <jenglish@users.sourceforge.net>
+
+ * generic/ttk/ttkTreeview.c: Fix crash in 'tag add' / 'tag remove'
+ commands when no -tags specified [Bug 3085489].
+
2010-10-06 Donal K. Fellows <dkf@users.sf.net>
* win/Makefile.in (genstubs): [Tcl Bug 3082049]: Typo.
diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c
index 58ff7f0..fca8aa7 100644
--- a/generic/ttk/ttkTreeview.c
+++ b/generic/ttk/ttkTreeview.c
@@ -1,4 +1,4 @@
-/* $Id: ttkTreeview.c,v 1.23.2.3 2010/09/08 17:57:52 jenglish Exp $
+/* $Id: ttkTreeview.c,v 1.23.2.4 2010/10/11 21:35:27 jenglish Exp $
* Copyright (c) 2004, Joe English
*
* ttk::treeview widget implementation.
@@ -3140,7 +3140,7 @@ static int TreeviewTagNamesCommand(
static void AddTag(TreeItem *item, Ttk_Tag tag)
{
if (Ttk_TagSetAdd(item->tagset, tag)) {
- Tcl_DecrRefCount(item->tagsObj);
+ if (item->tagsObj) Tcl_DecrRefCount(item->tagsObj);
item->tagsObj = Ttk_NewTagSetObj(item->tagset);
Tcl_IncrRefCount(item->tagsObj);
}
@@ -3173,12 +3173,12 @@ static int TreeviewTagAddCommand(
return TCL_OK;
}
-/* + $tv tag remove $tag $items
+/* + $tv tag remove $tag ?$items?
*/
static void RemoveTag(TreeItem *item, Ttk_Tag tag)
{
if (Ttk_TagSetRemove(item->tagset, tag)) {
- Tcl_DecrRefCount(item->tagsObj);
+ if (item->tagsObj) Tcl_DecrRefCount(item->tagsObj);
item->tagsObj = Ttk_NewTagSetObj(item->tagset);
Tcl_IncrRefCount(item->tagsObj);
}
diff --git a/tests/ttk/treeview.test b/tests/ttk/treeview.test
index 5bc7a80..73d2dce 100644
--- a/tests/ttk/treeview.test
+++ b/tests/ttk/treeview.test
@@ -1,5 +1,5 @@
#
-# $Id: treeview.test,v 1.3.2.3 2010/08/26 02:06:10 hobbs Exp $
+# $Id: treeview.test,v 1.3.2.4 2010/10/11 21:35:27 jenglish Exp $
#
# [7Jun2005] TO CHECK: [$tv see {}] -- shouldn't work (at least, shouldn't do
# what it currently does)
@@ -571,7 +571,7 @@ test treeview-identify-8 "identify element" -body {
} -match glob -result [list \
branch $disclosure branch2 $disclosure branch3 $disclosure]
-# See #2381555
+# See #2381555
test treeview-identify-9 "identify works when horizontally scrolled" -setup {
.tv configure -show {tree headings}
foreach column {#0 A B C} {
@@ -618,4 +618,24 @@ test treeview-3006842 "Null bindings" -setup {
destroy .tv
}
+test treeview-3085489-1 "tag add, no -tags" -setup {
+ ttk::treeview .tv
+} -body {
+ set item [.tv insert {} end]
+ .tv tag add foo $item
+ .tv item $item -tags
+} -cleanup {
+ destroy .tv
+} -result [list foo]
+
+test treeview-3085489-2 "tag remove, no -tags" -setup {
+ ttk::treeview .tv
+} -body {
+ set item [.tv insert {} end]
+ .tv tag remove foo $item
+ .tv item $item -tags
+} -cleanup {
+ destroy .tv
+} -result [list]
+
tcltest::cleanupTests