summaryrefslogtreecommitdiffstats
path: root/generic/tk3d.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2000-05-11 22:37:05 (GMT)
committerhobbs <hobbs>2000-05-11 22:37:05 (GMT)
commit019b002c433bcd9f30920845f750845b0c047ef8 (patch)
tree5186d3f9e79d9d2c7d3b683a557385c781412add /generic/tk3d.c
parent5a144b535bc726066340b42e20955732a1ffabe3 (diff)
downloadtk-019b002c433bcd9f30920845f750845b0c047ef8.zip
tk-019b002c433bcd9f30920845f750845b0c047ef8.tar.gz
tk-019b002c433bcd9f30920845f750845b0c047ef8.tar.bz2
* tests/menu.test:
* generic/tk3d.c: * generic/tkColor.c: * generic/tkCursor.c: corrected handling of 3DBorder, Cursor and Color objects on multiple screens. [Bug: 5454]
Diffstat (limited to 'generic/tk3d.c')
-rw-r--r--generic/tk3d.c54
1 files changed, 32 insertions, 22 deletions
diff --git a/generic/tk3d.c b/generic/tk3d.c
index 805c6bc..5147e95 100644
--- a/generic/tk3d.c
+++ b/generic/tk3d.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tk3d.c,v 1.7 2000/05/10 00:09:38 ericm Exp $
+ * RCS: @(#) $Id: tk3d.c,v 1.8 2000/05/11 22:37:06 hobbs Exp $
*/
#include "tk3d.h"
@@ -502,6 +502,7 @@ Tk_Free3DBorderFromObj(tkwin, objPtr)
Tcl_Obj *objPtr; /* The Tcl_Obj * to be freed. */
{
Tk_Free3DBorder(Tk_Get3DBorderFromObj(tkwin, objPtr));
+ FreeBorderObjProc(objPtr);
}
/*
@@ -1268,37 +1269,46 @@ Tk_Get3DBorderFromObj(tkwin, objPtr)
InitBorderObj(objPtr);
}
- borderPtr = (TkBorder *) objPtr->internalRep.twoPtrValue.ptr1;
- if (borderPtr != NULL) {
- if ((borderPtr->resourceRefCount > 0)
- && (Tk_Screen(tkwin) == borderPtr->screen)
- && (Tk_Colormap(tkwin) == borderPtr->colormap)) {
- /*
- * The object already points to the right border structure.
- * Just return it.
- */
+ /*
+ * If we are lucky (and the user doesn't use too many different
+ * displays, screens, or colormaps...) then the TkBorder
+ * structure we need will be cached in the internal
+ * representation of the Tcl_Obj. Check it out...
+ */
- return (Tk_3DBorder) borderPtr;
- }
- hashPtr = borderPtr->hashPtr;
- FreeBorderObjProc(objPtr);
- } else {
- hashPtr = Tcl_FindHashEntry(&dispPtr->borderTable,
- Tcl_GetString(objPtr));
- if (hashPtr == NULL) {
- goto error;
- }
+ borderPtr = (TkBorder *) objPtr->internalRep.twoPtrValue.ptr1;
+ if ((borderPtr != NULL)
+ && (borderPtr->resourceRefCount > 0)
+ && (Tk_Screen(tkwin) == borderPtr->screen)
+ && (Tk_Colormap(tkwin) == borderPtr->colormap)) {
+ /*
+ * The object already points to the right border structure.
+ * Just return it.
+ */
+ return (Tk_3DBorder) borderPtr;
}
/*
- * At this point we've got a hash table entry, off of which hang
- * one or more TkBorder structures. See if any of them will work.
+ * If we make it here, it means we aren't so lucky. Either there
+ * was no cached TkBorder in the Tcl_Obj, or the TkBorder that was
+ * there is for the wrong screen/colormap. Either way, we have
+ * to search for the right TkBorder. For each color name, there is
+ * linked list of TkBorder structures, one structure for each
+ * screen/colormap combination. The head of the linked list is
+ * recorded in a hash table (where the key is the color name)
+ * attached to the TkDisplay structure. Walk this list to find
+ * the right TkBorder structure.
*/
+ hashPtr = Tcl_FindHashEntry(&dispPtr->borderTable, Tcl_GetString(objPtr));
+ if (hashPtr == NULL) {
+ goto error;
+ }
for (borderPtr = (TkBorder *) Tcl_GetHashValue(hashPtr);
(borderPtr != NULL); borderPtr = borderPtr->nextPtr) {
if ((Tk_Screen(tkwin) == borderPtr->screen)
&& (Tk_Colormap(tkwin) == borderPtr->colormap)) {
+ FreeBorderObjProc(objPtr);
objPtr->internalRep.twoPtrValue.ptr1 = (VOID *) borderPtr;
borderPtr->objRefCount++;
return (Tk_3DBorder) borderPtr;