summaryrefslogtreecommitdiffstats
path: root/generic/tkImage.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2003-05-08 09:35:41 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2003-05-08 09:35:41 (GMT)
commit780c535e9d5a3d6e29f9dd81118a3e690e7856c4 (patch)
tree88a8f7260a315993d69e01f0c55ddf02a2a0692f /generic/tkImage.c
parent5c9f8f05e4dfc06c68a3bc1ec7c69b47683d9c51 (diff)
downloadtk-780c535e9d5a3d6e29f9dd81118a3e690e7856c4.zip
tk-780c535e9d5a3d6e29f9dd81118a3e690e7856c4.tar.gz
tk-780c535e9d5a3d6e29f9dd81118a3e690e7856c4.tar.bz2
Stop deleted images from showing up in the various [image *] operations.
Can't delete early though as that removes the link with widgets and image names.
Diffstat (limited to 'generic/tkImage.c')
-rw-r--r--generic/tkImage.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/generic/tkImage.c b/generic/tkImage.c
index feb65ab..651c675 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.20 2003/05/08 09:35:41 dkf Exp $
*/
#include "tkInt.h"
@@ -293,6 +293,7 @@ Tk_ImageObjCmd(clientData, interp, objc, objv)
(*masterPtr->typePtr->deleteProc)(masterPtr->masterData);
masterPtr->typePtr = NULL;
}
+ masterPtr->deleted = 0;
}
/*
@@ -343,11 +344,16 @@ Tk_ImageObjCmd(clientData, interp, objc, objv)
char *arg = Tcl_GetString(objv[i]);
hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, arg);
if (hPtr == NULL) {
+ deleteAlreadyDeleted:
Tcl_AppendResult(interp, "image \"", arg,
"\" doesn't exist", (char *) NULL);
return TCL_ERROR;
}
- DeleteImage((ImageMaster *) Tcl_GetHashValue(hPtr));
+ masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
+ if (masterPtr->deleted) {
+ goto deleteAlreadyDeleted;
+ }
+ DeleteImage(masterPtr);
}
break;
}
@@ -360,11 +366,15 @@ Tk_ImageObjCmd(clientData, interp, objc, objv)
arg = Tcl_GetString(objv[2]);
hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, arg);
if (hPtr == NULL) {
+ heightAlreadyDeleted:
Tcl_AppendResult(interp, "image \"", arg,
"\" doesn't exist", (char *) NULL);
return TCL_ERROR;
}
masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
+ if (masterPtr->deleted) {
+ goto heightAlreadyDeleted;
+ }
Tcl_SetIntObj(Tcl_GetObjResult(interp), masterPtr->height);
break;
}
@@ -379,11 +389,15 @@ Tk_ImageObjCmd(clientData, interp, objc, objv)
arg = Tcl_GetString(objv[2]);
hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, arg);
if (hPtr == NULL) {
+ inuseAlreadyDeleted:
Tcl_AppendResult(interp, "image \"", arg,
"\" doesn't exist", (char *) NULL);
return TCL_ERROR;
}
masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
+ if (masterPtr->deleted) {
+ goto inuseAlreadyDeleted;
+ }
if (masterPtr->typePtr != NULL && masterPtr->instancePtr != NULL) {
count = 1;
}
@@ -398,6 +412,10 @@ Tk_ImageObjCmd(clientData, interp, objc, objv)
}
hPtr = Tcl_FirstHashEntry(&winPtr->mainPtr->imageTable, &search);
for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
+ masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
+ if (masterPtr->deleted) {
+ continue;
+ }
Tcl_AppendElement(interp, Tcl_GetHashKey(
&winPtr->mainPtr->imageTable, hPtr));
}
@@ -413,11 +431,15 @@ Tk_ImageObjCmd(clientData, interp, objc, objv)
arg = Tcl_GetString(objv[2]);
hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, arg);
if (hPtr == NULL) {
+ typeAlreadyDeleted:
Tcl_AppendResult(interp, "image \"", arg,
"\" doesn't exist", (char *) NULL);
return TCL_ERROR;
}
masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
+ if (masterPtr->deleted) {
+ goto typeAlreadyDeleted;
+ }
if (masterPtr->typePtr != NULL) {
Tcl_SetResult(interp, masterPtr->typePtr->name, TCL_STATIC);
}
@@ -447,11 +469,15 @@ Tk_ImageObjCmd(clientData, interp, objc, objv)
arg = Tcl_GetString(objv[2]);
hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, arg);
if (hPtr == NULL) {
+ widthAlreadyDeleted:
Tcl_AppendResult(interp, "image \"", arg,
"\" doesn't exist", (char *) NULL);
return TCL_ERROR;
}
masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
+ if (masterPtr->deleted) {
+ goto widthAlreadyDeleted;
+ }
Tcl_SetIntObj(Tcl_GetObjResult(interp), masterPtr->width);
break;
}
@@ -578,6 +604,9 @@ Tk_GetImage(interp, tkwin, name, changeProc, clientData)
if (masterPtr->typePtr == NULL) {
goto noSuchImage;
}
+ if (masterPtr->deleted) {
+ goto noSuchImage;
+ }
imagePtr = (Image *) ckalloc(sizeof(Image));
imagePtr->tkwin = tkwin;
imagePtr->display = Tk_Display(tkwin);
@@ -926,6 +955,8 @@ DeleteImage(masterPtr)
Tcl_DeleteHashEntry(masterPtr->hPtr);
Tcl_Release((ClientData) masterPtr->winPtr);
ckfree((char *) masterPtr);
+ } else {
+ masterPtr->deleted = 1;
}
}
@@ -1032,6 +1063,10 @@ Tk_GetImageMasterData(interp, name, typePtrPtr)
return NULL;
}
masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
+ if (masterPtr->deleted) {
+ *typePtrPtr = NULL;
+ return NULL;
+ }
*typePtrPtr = masterPtr->typePtr;
return masterPtr->masterData;
}