diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | generic/tkImage.c | 27 |
2 files changed, 26 insertions, 7 deletions
@@ -1,3 +1,9 @@ +2003-07-07 Donal K. Fellows <fellowsd@cs.man.ac.uk> + + * generic/tkImage.c (TkDeleteAllImages,etc.): Stopped the deleting + of hash entries from a table that has just been deleted by this + function when some images are Tcl_Preserve()d... [Bug 749353] + 2003-05-20 Jeff Hobbs <jeffh@ActiveState.com> *** 8.4.3 TAGGED FOR RELEASE *** diff --git a/generic/tkImage.c b/generic/tkImage.c index feb65ab..78e2a56 100644 --- a/generic/tkImage.c +++ b/generic/tkImage.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: tkImage.c,v 1.19 2003/01/22 14:32:59 dkf Exp $ + * RCS: @(#) $Id: tkImage.c,v 1.19.2.1 2003/07/07 09:43:01 dkf Exp $ */ #include "tkInt.h" @@ -87,7 +87,8 @@ static Tcl_ThreadDataKey dataKey; */ static void DeleteImage _ANSI_ARGS_((ImageMaster *masterPtr)); -static void EventuallyDeleteImage _ANSI_ARGS_((ImageMaster *masterPtr)); +static void EventuallyDeleteImage _ANSI_ARGS_((ImageMaster *masterPtr, + int forgetHashEntryNow)); /* *---------------------------------------------------------------------- @@ -316,7 +317,7 @@ Tk_ImageObjCmd(clientData, interp, objc, objv) if ((*typePtr->createProc)(interp, name, objc, args, typePtr, (Tk_ImageMaster) masterPtr, &masterPtr->masterData) != TCL_OK) { - EventuallyDeleteImage(masterPtr); + EventuallyDeleteImage(masterPtr, 0); Tcl_Release((ClientData) masterPtr); if (oldimage) { ckfree((char *) args); @@ -527,6 +528,9 @@ Tk_NameOfImage(imageMaster) { ImageMaster *masterPtr = (ImageMaster *) imageMaster; + if (masterPtr->hPtr == NULL) { + return NULL; + } return Tcl_GetHashKey(masterPtr->tablePtr, masterPtr->hPtr); } @@ -648,7 +652,10 @@ Tk_FreeImage(image) */ if ((masterPtr->typePtr == NULL) && (masterPtr->instancePtr == NULL)) { - Tcl_DeleteHashEntry(masterPtr->hPtr); + if (masterPtr->hPtr != NULL) { + Tcl_DeleteHashEntry(masterPtr->hPtr); + } + Tcl_Release(masterPtr->winPtr); ckfree((char *) masterPtr); } } @@ -923,7 +930,9 @@ DeleteImage(masterPtr) (*typePtr->deleteProc)(masterPtr->masterData); } if (masterPtr->instancePtr == NULL) { - Tcl_DeleteHashEntry(masterPtr->hPtr); + if (masterPtr->hPtr != NULL) { + Tcl_DeleteHashEntry(masterPtr->hPtr); + } Tcl_Release((ClientData) masterPtr->winPtr); ckfree((char *) masterPtr); } @@ -948,9 +957,13 @@ DeleteImage(masterPtr) */ static void -EventuallyDeleteImage(masterPtr) +EventuallyDeleteImage(masterPtr, forgetHashEntryNow) ImageMaster *masterPtr; /* Pointer to main data structure for image. */ + int forgetHashEntryNow; { + if (forgetHashEntryNow) { + masterPtr->hPtr = NULL; + } if (!masterPtr->deleted) { masterPtr->deleted = 1; Tcl_EventuallyFree((ClientData) masterPtr, @@ -987,7 +1000,7 @@ TkDeleteAllImages(mainPtr) for (hPtr = Tcl_FirstHashEntry(&mainPtr->imageTable, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - EventuallyDeleteImage((ImageMaster *) Tcl_GetHashValue(hPtr)); + EventuallyDeleteImage((ImageMaster *) Tcl_GetHashValue(hPtr), 1); } Tcl_DeleteHashTable(&mainPtr->imageTable); } |