summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhobbs <hobbs>2006-05-29 21:52:47 (GMT)
committerhobbs <hobbs>2006-05-29 21:52:47 (GMT)
commit843f3e406c6e4cfad692db418c39912f538e25d6 (patch)
treee8601b4d9d9447943bc935ddbbb8246e8ed71a56
parenta053e2dbfdbece77b6327687523cec416d6821fd (diff)
downloadtk-843f3e406c6e4cfad692db418c39912f538e25d6.zip
tk-843f3e406c6e4cfad692db418c39912f538e25d6.tar.gz
tk-843f3e406c6e4cfad692db418c39912f538e25d6.tar.bz2
* tests/entry.test (entry-22.1):
* tests/listbox.test (listbox-6.15): * generic/tkListbox.c (ListboxInsertSubCmd, ListboxDeleteSubCmd): Ignore Tcl_SetVar2Ex failure of listVarName, similar to entry widget handling. [Bug 1424513]
-rw-r--r--ChangeLog8
-rw-r--r--generic/tkListbox.c46
-rw-r--r--tests/entry.test14
-rw-r--r--tests/listbox.test14
4 files changed, 56 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index 7342899..6a459f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-05-29 Jeff Hobbs <jeffh@ActiveState.com>
+
+ * tests/entry.test (entry-22.1):
+ * tests/listbox.test (listbox-6.15):
+ * generic/tkListbox.c (ListboxInsertSubCmd, ListboxDeleteSubCmd):
+ Ignore Tcl_SetVar2Ex failure of listVarName, similar to entry
+ widget handling. [Bug 1424513]
+
2006-05-26 Jeff Hobbs <jeffh@ActiveState.com>
* macosx/tkMacOSXButton.c (TkMacOSXDrawControl): correct redraw
diff --git a/generic/tkListbox.c b/generic/tkListbox.c
index fd02a27..43342c4 100644
--- a/generic/tkListbox.c
+++ b/generic/tkListbox.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkListbox.c,v 1.29.2.2 2004/06/08 20:11:18 dgp Exp $
+ * RCS: @(#) $Id: tkListbox.c,v 1.29.2.3 2006/05/29 21:52:47 hobbs Exp $
*/
#include "tkPort.h"
@@ -2284,25 +2284,24 @@ ListboxInsertSubCmd(listPtr, index, objc, objv)
return result;
}
+ /*
+ * Replace the current object and set attached listvar, if any.
+ * This may error if listvar points to a var in a deleted namespace, but
+ * we ignore those errors. If the namespace is recreated, it will
+ * auto-sync with the current value. [Bug 1424513]
+ */
+
Tcl_IncrRefCount(newListObj);
- /* Clean up the old reference */
Tcl_DecrRefCount(listPtr->listObj);
-
- /* Set the internal pointer to the new obj */
listPtr->listObj = newListObj;
-
- /* If there is a listvar, make sure it points at the new object */
if (listPtr->listVarName != NULL) {
- if (Tcl_SetVar2Ex(listPtr->interp, listPtr->listVarName,
- (char *)NULL, newListObj, TCL_GLOBAL_ONLY) == NULL) {
- Tcl_DecrRefCount(newListObj);
- return TCL_ERROR;
- }
+ Tcl_SetVar2Ex(listPtr->interp, listPtr->listVarName,
+ (char *) NULL, listPtr->listObj, TCL_GLOBAL_ONLY);
}
/* Get the new list length */
Tcl_ListObjLength(listPtr->interp, listPtr->listObj, &listPtr->nElements);
-
+
/*
* Update the "special" indices (anchor, topIndex, active) to account
* for the renumbering that just occurred. Then arrange for the new
@@ -2433,24 +2432,23 @@ ListboxDeleteSubCmd(listPtr, first, last)
return result;
}
+ /*
+ * Replace the current object and set attached listvar, if any.
+ * This may error if listvar points to a var in a deleted namespace, but
+ * we ignore those errors. If the namespace is recreated, it will
+ * auto-sync with the current value. [Bug 1424513]
+ */
+
Tcl_IncrRefCount(newListObj);
- /* Clean up the old reference */
Tcl_DecrRefCount(listPtr->listObj);
-
- /* Set the internal pointer to the new obj */
listPtr->listObj = newListObj;
+ if (listPtr->listVarName != NULL) {
+ Tcl_SetVar2Ex(listPtr->interp, listPtr->listVarName,
+ (char *) NULL, listPtr->listObj, TCL_GLOBAL_ONLY);
+ }
/* Get the new list length */
Tcl_ListObjLength(listPtr->interp, listPtr->listObj, &listPtr->nElements);
-
- /* If there is a listvar, make sure it points at the new object */
- if (listPtr->listVarName != NULL) {
- if (Tcl_SetVar2Ex(listPtr->interp, listPtr->listVarName,
- (char *)NULL, newListObj, TCL_GLOBAL_ONLY) == NULL) {
- Tcl_DecrRefCount(newListObj);
- return TCL_ERROR;
- }
- }
/*
* Update the selection and viewing information to reflect the change
diff --git a/tests/entry.test b/tests/entry.test
index 101a0c6..4030152 100644
--- a/tests/entry.test
+++ b/tests/entry.test
@@ -6,7 +6,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: entry.test,v 1.14 2003/02/25 00:46:41 hobbs Exp $
+# RCS: @(#) $Id: entry.test,v 1.14.2.1 2006/05/29 21:52:47 hobbs Exp $
package require tcltest 2.1
namespace import -force tcltest::configure
@@ -1613,6 +1613,18 @@ test entry-21.1 {selection present while disabled, bug 637828} {
lappend out [.e selection present] [selection get]
} {1 1 345}
+test entry-22.1 {lost namespaced textvar} {
+ destroy .e
+ namespace eval test { variable foo {a b} }
+ entry .e -textvariable ::test::foo
+ namespace delete test
+ .e insert end "more stuff"
+ .e delete 5 end
+ catch {set ::test::foo} result
+ list [.e get] [.e cget -textvar] $result
+} [list "a bmo" ::test::foo \
+ {can't read "::test::foo": no such variable}]
+
destroy .e
# XXX Still need to write tests for EntryBlinkProc, EntryFocusProc,
diff --git a/tests/listbox.test b/tests/listbox.test
index a6f858c..29e629e 100644
--- a/tests/listbox.test
+++ b/tests/listbox.test
@@ -6,7 +6,7 @@
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
-# RCS: @(#) $Id: listbox.test,v 1.21.2.1 2003/10/13 00:55:25 hobbs Exp $
+# RCS: @(#) $Id: listbox.test,v 1.21.2.2 2006/05/29 21:52:47 hobbs Exp $
package require tcltest 2.1
namespace import -force tcltest::configure
@@ -1109,6 +1109,18 @@ test listbox-6.14 {InsertEls procedure, check selection update} {
.l2 insert 0 a
.l2 curselection
} [list 3 4 5]
+test listbox-6.15 {InsertEls procedure, lost namespaced listvar, bug 1424513} {
+ destroy .l2
+ namespace eval test { variable foo {a b} }
+ listbox .l2 -listvar ::test::foo
+ namespace delete test
+ .l2 insert end c d
+ .l2 delete end
+ .l2 insert end e f
+ catch {set ::test::foo} result
+ list [.l2 get 0 end] [.l2 cget -listvar] $result
+} [list [list a b c e f] ::test::foo \
+ {can't read "::test::foo": no such variable}]
test listbox-7.1 {DeleteEls procedure} {