diff options
author | hobbs <hobbs> | 2001-04-03 04:41:08 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2001-04-03 04:41:08 (GMT) |
commit | 553b8f028b34922f9cb037598eea703141abee5b (patch) | |
tree | 0ee52a4755cfc619e731dbddf8f550b6ff5a1e0d /generic | |
parent | edbaf5d094e716436538e73173a65bce146a5a3d (diff) | |
download | tk-553b8f028b34922f9cb037598eea703141abee5b.zip tk-553b8f028b34922f9cb037598eea703141abee5b.tar.gz tk-553b8f028b34922f9cb037598eea703141abee5b.tar.bz2 |
* tests/listbox.test: added test listbox-27.1, delete during
scrollbar update
* generic/tkListbox.c (DestroyListbox, ListboxEventProc):
corrected listbox to make proper use of Tcl_EventuallyFree and
protect against unusual listbox deletion.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkListbox.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 25e8563..6c45dfd 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.19 2000/11/22 01:49:38 ericm Exp $ + * RCS: @(#) $Id: tkListbox.c,v 1.20 2001/04/03 04:41:08 hobbs Exp $ */ #include "tkPort.h" @@ -1456,16 +1456,6 @@ DestroyListbox(memPtr) Tcl_HashEntry *entry; Tcl_HashSearch search; - listPtr->flags |= LISTBOX_DELETED; - - Tcl_DeleteCommandFromToken(listPtr->interp, listPtr->widgetCmd); - if (listPtr->setGrid) { - Tk_UnsetGrid(listPtr->tkwin); - } - if (listPtr->flags & REDRAW_PENDING) { - Tcl_CancelIdleCall(DisplayListbox, (ClientData) listPtr); - } - /* If we have an internal list object, free it */ if (listPtr->listObj != NULL) { Tcl_DecrRefCount(listPtr->listObj); @@ -1834,6 +1824,9 @@ DisplayListbox(clientData) Pixmap pixmap; listPtr->flags &= ~REDRAW_PENDING; + if (listPtr->flags & LISTBOX_DELETED) { + return; + } if (listPtr->flags & MAXWIDTH_IS_STALE) { ListboxComputeGeometry(listPtr, 0, 1, 0); @@ -1848,7 +1841,7 @@ DisplayListbox(clientData) ListboxUpdateHScrollbar(listPtr); } listPtr->flags &= ~(REDRAW_PENDING|UPDATE_V_SCROLLBAR|UPDATE_H_SCROLLBAR); - if ((listPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { + if ((listPtr->flags & LISTBOX_DELETED) || (!Tk_IsMapped(tkwin))) { return; } @@ -2453,7 +2446,17 @@ ListboxEventProc(clientData, eventPtr) NearestListboxElement(listPtr, eventPtr->xexpose.y + eventPtr->xexpose.height)); } else if (eventPtr->type == DestroyNotify) { - DestroyListbox((char *) clientData); + if (!(listPtr->flags & LISTBOX_DELETED)) { + listPtr->flags |= LISTBOX_DELETED; + Tcl_DeleteCommandFromToken(listPtr->interp, listPtr->widgetCmd); + if (listPtr->setGrid) { + Tk_UnsetGrid(listPtr->tkwin); + } + if (listPtr->flags & REDRAW_PENDING) { + Tcl_CancelIdleCall(DisplayListbox, clientData); + } + Tcl_EventuallyFree(clientData, DestroyListbox); + } } else if (eventPtr->type == ConfigureNotify) { int vertSpace; @@ -3067,7 +3070,7 @@ EventuallyRedrawRange(listPtr, first, last) /* We don't have to register a redraw callback if one is already pending, * or if the window doesn't exist, or if the window isn't mapped */ if ((listPtr->flags & REDRAW_PENDING) - || (listPtr->tkwin == NULL) + || (listPtr->flags & LISTBOX_DELETED) || !Tk_IsMapped(listPtr->tkwin)) { return; } |