~ubuntu-branches/ubuntu/gutsy/tk8.4/gutsy-updates

« back to all changes in this revision

Viewing changes to generic/tkListbox.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-01-05 15:56:45 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070105155645-8srmlwqo7m1q86qi
Tags: 8.4.14-0ubuntu1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
13
13
 *
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 $
15
15
 */
16
16
 
17
17
#include "tkPort.h"
2284
2284
        return result;
2285
2285
    }
2286
2286
 
 
2287
    /*
 
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]
 
2292
     */
 
2293
 
2287
2294
    Tcl_IncrRefCount(newListObj);
2288
 
    /* Clean up the old reference */
2289
2295
    Tcl_DecrRefCount(listPtr->listObj);
2290
 
 
2291
 
    /* Set the internal pointer to the new obj */
2292
2296
    listPtr->listObj = newListObj;
2293
 
 
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);
2299
 
            return TCL_ERROR;
2300
 
        }
 
2298
        Tcl_SetVar2Ex(listPtr->interp, listPtr->listVarName,
 
2299
                (char *) NULL, listPtr->listObj, TCL_GLOBAL_ONLY);
2301
2300
    }
2302
2301
 
2303
2302
    /* Get the new list length */
2304
2303
    Tcl_ListObjLength(listPtr->interp, listPtr->listObj, &listPtr->nElements);
2305
 
    
 
2304
 
2306
2305
    /*
2307
2306
     * Update the "special" indices (anchor, topIndex, active) to account
2308
2307
     * for the renumbering that just occurred.  Then arrange for the new
2433
2432
        return result;
2434
2433
    }
2435
2434
 
 
2435
    /*
 
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]
 
2440
     */
 
2441
 
2436
2442
    Tcl_IncrRefCount(newListObj);
2437
 
    /* Clean up the old reference */
2438
2443
    Tcl_DecrRefCount(listPtr->listObj);
2439
 
 
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);
 
2448
    }
2442
2449
 
2443
2450
    /* Get the new list length */
2444
2451
    Tcl_ListObjLength(listPtr->interp, listPtr->listObj, &listPtr->nElements);
2445
 
    
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);
2451
 
            return TCL_ERROR;
2452
 
        }
2453
 
    }
2454
2452
 
2455
2453
    /*
2456
2454
     * Update the selection and viewing information to reflect the change