11
11
* See the file "license.terms" for information on usage and redistribution
12
12
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14
* RCS: @(#) $Id: tkListbox.c,v 1.29.2.2 2004/06/08 20:11:18 dgp Exp $
14
* RCS: @(#) $Id: tkListbox.c,v 1.29.2.3 2006/05/29 21:52:47 hobbs Exp $
17
17
#include "tkPort.h"
2288
* Replace the current object and set attached listvar, if any.
2289
* This may error if listvar points to a var in a deleted namespace, but
2290
* we ignore those errors. If the namespace is recreated, it will
2291
* auto-sync with the current value. [Bug 1424513]
2287
2294
Tcl_IncrRefCount(newListObj);
2288
/* Clean up the old reference */
2289
2295
Tcl_DecrRefCount(listPtr->listObj);
2291
/* Set the internal pointer to the new obj */
2292
2296
listPtr->listObj = newListObj;
2294
/* If there is a listvar, make sure it points at the new object */
2295
2297
if (listPtr->listVarName != NULL) {
2296
if (Tcl_SetVar2Ex(listPtr->interp, listPtr->listVarName,
2297
(char *)NULL, newListObj, TCL_GLOBAL_ONLY) == NULL) {
2298
Tcl_DecrRefCount(newListObj);
2298
Tcl_SetVar2Ex(listPtr->interp, listPtr->listVarName,
2299
(char *) NULL, listPtr->listObj, TCL_GLOBAL_ONLY);
2303
2302
/* Get the new list length */
2304
2303
Tcl_ListObjLength(listPtr->interp, listPtr->listObj, &listPtr->nElements);
2307
2306
* Update the "special" indices (anchor, topIndex, active) to account
2308
2307
* for the renumbering that just occurred. Then arrange for the new
2436
* Replace the current object and set attached listvar, if any.
2437
* This may error if listvar points to a var in a deleted namespace, but
2438
* we ignore those errors. If the namespace is recreated, it will
2439
* auto-sync with the current value. [Bug 1424513]
2436
2442
Tcl_IncrRefCount(newListObj);
2437
/* Clean up the old reference */
2438
2443
Tcl_DecrRefCount(listPtr->listObj);
2440
/* Set the internal pointer to the new obj */
2441
2444
listPtr->listObj = newListObj;
2445
if (listPtr->listVarName != NULL) {
2446
Tcl_SetVar2Ex(listPtr->interp, listPtr->listVarName,
2447
(char *) NULL, listPtr->listObj, TCL_GLOBAL_ONLY);
2443
2450
/* Get the new list length */
2444
2451
Tcl_ListObjLength(listPtr->interp, listPtr->listObj, &listPtr->nElements);
2446
/* If there is a listvar, make sure it points at the new object */
2447
if (listPtr->listVarName != NULL) {
2448
if (Tcl_SetVar2Ex(listPtr->interp, listPtr->listVarName,
2449
(char *)NULL, newListObj, TCL_GLOBAL_ONLY) == NULL) {
2450
Tcl_DecrRefCount(newListObj);
2456
2454
* Update the selection and viewing information to reflect the change