   * Apply 3 changes based on revisions developed by the fedora linux team.
 --> + 03-fedora-patch-2.diff
     + 04-fedora-tk8.5.6.patch.diff
     + 05-tk8.5-zoomstack.diff
    * Those patches are required to solve segmentation faults that are observed
     when blt is used with tcltk 8.5. We have a substantial amount of
     experience using this patched version of blt in the Swarm
     Simulation System (www.swarm.org) and have observed no ill-effects.
Author: Paul E. Johnson (Debian Packaging) <pauljohn32@freefaculty.org>

--- blt-2.4z.orig/src/bltInit.c
+++ blt-2.4z/src/bltInit.c
@@ -38,17 +38,16 @@
 #endif
 #endif
 
+#define BLT_THREAD_KEY		"BLT Initialized"
+#define BLT_TCL_CMDS		(1<<0)
+#define BLT_TK_CMDS		(1<<1)
+
 double bltNaN;
 #if (TCL_MAJOR_VERSION > 7)
 Tcl_Obj *bltEmptyStringObjPtr;
 #endif
 
 static Tcl_MathProc MinMathProc, MaxMathProc;
-static int tclLoaded = FALSE;
-#ifndef TCL_ONLY
-static int tkLoaded = FALSE;
-#endif
-
 static char libPath[1024] =
 {
     BLT_LIBRARY
@@ -404,7 +403,10 @@ EXPORT int
 Blt_Init(interp)
     Tcl_Interp *interp;		/* Interpreter to add extra commands */
 {
-    if (!tclLoaded) {
+    int flags;
+
+    flags = (int)Tcl_GetAssocData(interp, BLT_THREAD_KEY, NULL);
+    if ((flags & BLT_TCL_CMDS) == 0) {
 	register Tcl_AppInitProc **p;
 	Tcl_Namespace *nsPtr;
 	Tcl_ValueType args[2];
@@ -451,10 +453,11 @@ Blt_Init(interp)
 	if (Tcl_PkgProvide(interp, "BLT", BLT_VERSION) != TCL_OK) {
 	    return TCL_ERROR;
 	}
-	tclLoaded = TRUE;
+	Tcl_SetAssocData(interp, BLT_THREAD_KEY, NULL, 
+		(ClientData)(flags | BLT_TCL_CMDS));
     }
 #ifndef TCL_ONLY
-    if (!tkLoaded) {
+    if ((flags & BLT_TK_CMDS) == 0) {
 	register Tcl_AppInitProc **p;
 	Tcl_Namespace *nsPtr;
 
@@ -486,7 +489,8 @@ Blt_Init(interp)
 	    }
 	}
 	Blt_InitEpsCanvasItem(interp);
-	tkLoaded = TRUE;
+	Tcl_SetAssocData(interp, BLT_THREAD_KEY, NULL, 
+		(ClientData)(flags | BLT_TK_CMDS));
     }
 #endif
     return TCL_OK;
@@ -499,7 +503,10 @@ EXPORT int
 Blt_Init(interp)
     Tcl_Interp *interp;		/* Interpreter to add extra commands */
 {
-    if (!tclLoaded) {
+    int flags;
+
+    flags = (int)Tcl_GetAssocData(interp, BLT_THREAD_KEY, NULL);
+    if ((flags & BLT_TCL_CMDS) == 0) {
 	register Tcl_AppInitProc **p;
 	Tcl_ValueType args[2];
 
@@ -537,10 +544,11 @@ Blt_Init(interp)
 	if (Tcl_PkgProvide(interp, "BLT", BLT_VERSION) != TCL_OK) {
 	    return TCL_ERROR;
 	}
-	tclLoaded = TRUE;
+	Tcl_SetAssocData(interp, BLT_THREAD_KEY, NULL, 
+		(ClientData)(flags | BLT_TCL_CMDS));
     }
 #ifndef TCL_ONLY
-    if (!tkLoaded) {
+    if ((flags & BLT_TK_CMDS) == 0) {
 	register Tcl_AppInitProc **p;
 
 #if (TCL_VERSION_NUMBER >= _VERSION(8,1,0)) 
@@ -560,7 +568,8 @@ Blt_Init(interp)
 	    }
 	}
 	Blt_InitEpsCanvasItem(interp);
-	tkLoaded = TRUE;
+	Tcl_SetAssocData(interp, BLT_THREAD_KEY, NULL, 
+		(ClientData)(flags | BLT_TK_CMDS));
     }
 #endif
     return TCL_OK;
--- blt-2.4z.orig/src/bltTreeView.c
+++ blt-2.4z/src/bltTreeView.c
@@ -3866,6 +3866,7 @@ ComputeVisibleEntries(TreeView *tvPtr)
 	assert(tvPtr->visibleArr);
     }
     tvPtr->nVisible = 0;
+    tvPtr->visibleArr[0] = NULL;
 
     if (tvPtr->rootPtr->flags & ENTRY_HIDDEN) {
 	return TCL_OK;		/* Root node is hidden. */
@@ -4631,6 +4632,9 @@ DrawTitle(
     int width;
     int x0, cx, xOffset;
 
+    if (tvPtr->titleHeight < 1) {
+	return;
+    }
     columnWidth = columnPtr->width;
     cx = x;
     if (columnPtr->position == Blt_ChainGetLength(tvPtr->colChainPtr)) {
--- blt-2.4z.orig/src/bltGrAxis.c
+++ blt-2.4z/src/bltGrAxis.c
@@ -1424,59 +1424,62 @@ LogScaleAxis(axisPtr, min, max)
     double majorStep, minorStep;
     int nMajor, nMinor;
 
-    min = (min != 0.0) ? log10(FABS(min)) : 0.0;
-    max = (max != 0.0) ? log10(FABS(max)) : 1.0;
-
-    tickMin = floor(min);
-    tickMax = ceil(max);
-    range = tickMax - tickMin;
-
-    if (range > 10) {
-	/* There are too many decades to display a major tick at every
-	 * decade.  Instead, treat the axis as a linear scale.  */
-	range = NiceNum(range, 0);
-	majorStep = NiceNum(range / DEF_NUM_TICKS, 1);
-	tickMin = UFLOOR(tickMin, majorStep);
-	tickMax = UCEIL(tickMax, majorStep);
-	nMajor = (int)((tickMax - tickMin) / majorStep) + 1;
-	minorStep = EXP10(floor(log10(majorStep)));
-	if (minorStep == majorStep) {
-	    nMinor = 4, minorStep = 0.2;
+    nMajor = nMinor = 0;
+    majorStep = minorStep = 0.0;
+    if (min < max) {
+	min = (min != 0.0) ? log10(FABS(min)) : 0.0;
+	max = (max != 0.0) ? log10(FABS(max)) : 1.0;
+	
+	tickMin = floor(min);
+	tickMax = ceil(max);
+	range = tickMax - tickMin;
+	
+	if (range > 10) {
+	    /* There are too many decades to display a major tick at every
+	     * decade.  Instead, treat the axis as a linear scale.  */
+	    range = NiceNum(range, 0);
+	    majorStep = NiceNum(range / DEF_NUM_TICKS, 1);
+	    tickMin = UFLOOR(tickMin, majorStep);
+	    tickMax = UCEIL(tickMax, majorStep);
+	    nMajor = (int)((tickMax - tickMin) / majorStep) + 1;
+	    minorStep = EXP10(floor(log10(majorStep)));
+	    if (minorStep == majorStep) {
+		nMinor = 4, minorStep = 0.2;
+	    } else {
+		nMinor = Round(majorStep / minorStep) - 1;
+	    }
 	} else {
-	    nMinor = Round(majorStep / minorStep) - 1;
-	}
-    } else {
-	if (tickMin == tickMax) {
-	    tickMax++;
-	}
-	majorStep = 1.0;
-	nMajor = (int)(tickMax - tickMin + 1); /* FIXME: Check this. */
-
-	minorStep = 0.0;	/* This is a special hack to pass
+	    if (tickMin == tickMax) {
+		tickMax++;
+	    }
+	    majorStep = 1.0;
+	    nMajor = (int)(tickMax - tickMin + 1); /* FIXME: Check this. */
+	    
+	    minorStep = 0.0;	/* This is a special hack to pass
 				 * information to the GenerateTicks
 				 * routine. An interval of 0.0 tells
 				 *	1) this is a minor sweep and 
 				 *	2) the axis is log scale.  
 				 */
-	nMinor = 10;
-    }
-    if ((axisPtr->looseMin == TICK_RANGE_TIGHT) ||
-	((axisPtr->looseMin == TICK_RANGE_LOOSE) && 
-	 (DEFINED(axisPtr->reqMin)))) {
-	tickMin = min;
-	nMajor++;
-    }
-    if ((axisPtr->looseMax == TICK_RANGE_TIGHT) ||
-	((axisPtr->looseMax == TICK_RANGE_LOOSE) &&
-	 (DEFINED(axisPtr->reqMax)))) {
-	tickMax = max;
+	    nMinor = 10;
+	}
+	if ((axisPtr->looseMin == TICK_RANGE_TIGHT) ||
+	    ((axisPtr->looseMin == TICK_RANGE_LOOSE) && 
+	     (DEFINED(axisPtr->reqMin)))) {
+	    tickMin = min;
+	    nMajor++;
+	}
+	if ((axisPtr->looseMax == TICK_RANGE_TIGHT) ||
+	    ((axisPtr->looseMax == TICK_RANGE_LOOSE) &&
+	     (DEFINED(axisPtr->reqMax)))) {
+	    tickMax = max;
+	}
     }
     axisPtr->majorSweep.step = majorStep;
     axisPtr->majorSweep.initial = floor(tickMin);
     axisPtr->majorSweep.nSteps = nMajor;
     axisPtr->minorSweep.initial = axisPtr->minorSweep.step = minorStep;
     axisPtr->minorSweep.nSteps = nMinor;
-
     SetAxisRange(&axisPtr->axisRange, tickMin, tickMax);
 }
 
@@ -1551,31 +1554,35 @@ LinearScaleAxis(axisPtr, min, max)
     double axisMin, axisMax;
     int nTicks;
 
-    range = max - min;
-
-    /* Calculate the major tick stepping. */
-    if (axisPtr->reqStep > 0.0) {
-	/* An interval was designated by the user.  Keep scaling it
-	 * until it fits comfortably within the current range of the
-	 * axis.  */
-	step = axisPtr->reqStep;
-	while ((2 * step) >= range) {
-	    step *= 0.5;
+    nTicks = 0;
+    tickMin = tickMax = 0.0;
+    if (min < max) {
+	range = max - min;
+	
+	/* Calculate the major tick stepping. */
+	if (axisPtr->reqStep > 0.0) {
+	    /* An interval was designated by the user.  Keep scaling it
+	     * until it fits comfortably within the current range of the
+	     * axis.  */
+	    step = axisPtr->reqStep;
+	    while ((2 * step) >= range) {
+		step *= 0.5;
+	    }
+	} else {
+	    range = NiceNum(range, 0);
+	    step = NiceNum(range / DEF_NUM_TICKS, 1);
 	}
-    } else {
-	range = NiceNum(range, 0);
-	step = NiceNum(range / DEF_NUM_TICKS, 1);
+	
+	/* Find the outer tick values. Add 0.0 to prevent getting -0.0. */
+	axisMin = tickMin = floor(min / step) * step + 0.0;
+	axisMax = tickMax = ceil(max / step) * step + 0.0;
+	
+	nTicks = Round((tickMax - tickMin) / step) + 1;
     }
-
-    /* Find the outer tick values. Add 0.0 to prevent getting -0.0. */
-    axisMin = tickMin = floor(min / step) * step + 0.0;
-    axisMax = tickMax = ceil(max / step) * step + 0.0;
-
-    nTicks = Round((tickMax - tickMin) / step) + 1;
     axisPtr->majorSweep.step = step;
     axisPtr->majorSweep.initial = tickMin;
     axisPtr->majorSweep.nSteps = nTicks;
-
+    
     /*
      * The limits of the axis are either the range of the data
      * ("tight") or at the next outer tick interval ("loose").  The
@@ -1596,9 +1603,9 @@ LinearScaleAxis(axisPtr, min, max)
 	axisMax = max;
     }
     SetAxisRange(&axisPtr->axisRange, axisMin, axisMax);
-
+    
     /* Now calculate the minor tick step and number. */
-
+    
     if ((axisPtr->reqNumMinorTicks > 0) && 
 	((axisPtr->flags & AXIS_CONFIG_MAJOR) == 0)) {
 	nTicks = axisPtr->reqNumMinorTicks - 1;
@@ -1614,7 +1621,6 @@ LinearScaleAxis(axisPtr, min, max)
     axisPtr->minorSweep.nSteps = nTicks;
 }
 
-
 static void
 SweepTicks(axisPtr)
     Axis *axisPtr;
@@ -1684,9 +1690,11 @@ Blt_ResetAxes(graphPtr)
     for (linkPtr = Blt_ChainFirstLink(graphPtr->elements.displayList);
 	linkPtr != NULL; linkPtr = Blt_ChainNextLink(linkPtr)) {
 	elemPtr = Blt_ChainGetValue(linkPtr);
-	(*elemPtr->procsPtr->extentsProc) (elemPtr, &exts);
-	GetDataLimits(elemPtr->axes.x, exts.left, exts.right);
-	GetDataLimits(elemPtr->axes.y, exts.top, exts.bottom);
+	if (!elemPtr->hidden) {
+	    (*elemPtr->procsPtr->extentsProc) (elemPtr, &exts);
+	    GetDataLimits(elemPtr->axes.x, exts.left, exts.right);
+	    GetDataLimits(elemPtr->axes.y, exts.top, exts.bottom);
+	}
     }
     /*
      * Step 3:  Now that we know the range of data values for each axis,
--- blt-2.4z.orig/src/bltGrMarker.c
+++ blt-2.4z/src/bltGrMarker.c
@@ -29,6 +29,9 @@
 #include "bltChain.h"
 #include "bltGrElem.h"
 
+#define GETBITMAP(b) \
+	(((b)->destBitmap == None) ? (b)->srcBitmap : (b)->destBitmap)
+
 #define MAX_OUTLINE_POINTS	12
 
 /* Map graph coordinates to normalized coordinates [0..1] */
@@ -812,7 +815,13 @@ typedef struct {
 
     /* Polygon specific attributes and fields */
 
-    Point2D *screenPts;
+    Point2D *screenPts;		/* Array of points representing the
+				 * polygon in screen coordinates. It's
+				 * not used for drawing, but to
+				 * generate the outlinePts and fillPts
+				 * arrays that are the coordinates of
+				 * the possibly clipped outline and
+				 * filled polygon. */
 
     ColorPair outline;
     ColorPair fill;
@@ -1565,9 +1574,6 @@ ConfigureBitmapMarker(markerPtr)
     if (bmPtr->srcBitmap == None) {
 	return TCL_OK;
     }
-    if (bmPtr->destBitmap == None) {
-	bmPtr->destBitmap = bmPtr->srcBitmap;
-    }
     bmPtr->theta = FMOD(bmPtr->rotate, 360.0);
     if (bmPtr->theta < 0.0) {
 	bmPtr->theta += 360.0;
@@ -1652,9 +1658,9 @@ MapBitmapMarker(markerPtr)
     if (bmPtr->srcBitmap == None) {
 	return;
     }
-    if (bmPtr->destBitmap != bmPtr->srcBitmap) {
+    if (bmPtr->destBitmap != None) {
 	Tk_FreePixmap(graphPtr->display, bmPtr->destBitmap);
-	bmPtr->destBitmap = bmPtr->srcBitmap;
+	bmPtr->destBitmap = None;
     }
     /* 
      * Collect the coordinates.  The number of coordinates will determine
@@ -1754,7 +1760,7 @@ MapBitmapMarker(markerPtr)
     } else {
 	bmPtr->destWidth = srcWidth;
 	bmPtr->destHeight = srcHeight;
-	bmPtr->destBitmap = bmPtr->srcBitmap;
+	bmPtr->destBitmap = None;
     }
     bmPtr->anchorPos = anchorPos;
     {
@@ -1911,9 +1917,10 @@ DrawBitmapMarker(markerPtr, drawable)
     Graph *graphPtr = markerPtr->graphPtr;
     BitmapMarker *bmPtr = (BitmapMarker *)markerPtr;
     double theta;
+    Pixmap bitmap;
 
-    if ((bmPtr->destBitmap == None) || (bmPtr->destWidth < 1) || 
-	(bmPtr->destHeight < 1)) {
+    bitmap = GETBITMAP(bmPtr);
+    if ((bitmap == None) || (bmPtr->destWidth < 1) || (bmPtr->destHeight < 1)) {
 	return;
     }
     theta = FMOD(bmPtr->theta, (double)90.0);
@@ -1936,14 +1943,14 @@ DrawBitmapMarker(markerPtr, drawable)
 	    XFillPolygon(graphPtr->display, drawable, bmPtr->fillGC,
 		 polygon, bmPtr->nOutlinePts, Convex, CoordModeOrigin);
 	}
-	XSetClipMask(graphPtr->display, bmPtr->gc, bmPtr->destBitmap);
+	XSetClipMask(graphPtr->display, bmPtr->gc, bitmap);
 	XSetClipOrigin(graphPtr->display, bmPtr->gc, (int)bmPtr->anchorPos.x, 
 	       (int)bmPtr->anchorPos.y);
     } else {
 	XSetClipMask(graphPtr->display, bmPtr->gc, None);
 	XSetClipOrigin(graphPtr->display, bmPtr->gc, 0, 0);
     }
-    XCopyPlane(graphPtr->display, bmPtr->destBitmap, drawable, bmPtr->gc, 0, 0,
+    XCopyPlane(graphPtr->display, bitmap, drawable, bmPtr->gc, 0, 0,
 	bmPtr->destWidth, bmPtr->destHeight, (int)bmPtr->anchorPos.x, 
 	(int)bmPtr->anchorPos.y, 1);
 }
@@ -1967,8 +1974,10 @@ BitmapMarkerToPostScript(markerPtr, psTo
 {
     Graph *graphPtr = markerPtr->graphPtr;
     BitmapMarker *bmPtr = (BitmapMarker *)markerPtr;
+    Pixmap bitmap;
 
-    if (bmPtr->destBitmap == None) {
+    bitmap = GETBITMAP(bmPtr);
+    if (bitmap == None) {
 	return;
     }
     if (bmPtr->fillColor != NULL) {
@@ -1984,7 +1993,7 @@ BitmapMarkerToPostScript(markerPtr, psTo
     Blt_FormatToPostScript(psToken, "    %d %d true [%d 0 0 %d 0 %d] {",
 	bmPtr->destWidth, bmPtr->destHeight, bmPtr->destWidth, 
 	-bmPtr->destHeight, bmPtr->destHeight);
-    Blt_BitmapDataToPostScript(psToken, graphPtr->display, bmPtr->destBitmap,
+    Blt_BitmapDataToPostScript(psToken, graphPtr->display, bitmap,
 	bmPtr->destWidth, bmPtr->destHeight);
     Blt_AppendToPostScript(psToken, "    } imagemask\n",
 	"grestore\n", (char *)NULL);
@@ -2020,7 +2029,7 @@ FreeBitmapMarker(graphPtr, markerPtr)
     if (bmPtr->fillGC != NULL) {
 	Tk_FreeGC(graphPtr->display, bmPtr->fillGC);
     }
-    if (bmPtr->destBitmap != bmPtr->srcBitmap) {
+    if (bmPtr->destBitmap != None) {
 	Tk_FreePixmap(graphPtr->display, bmPtr->destBitmap);
     }
 }
@@ -2129,8 +2138,6 @@ ConfigureImageMarker(markerPtr)
 	    imPtr->tkImage = Tk_GetImage(interp, graphPtr->tkwin,
 		imPtr->imageName, ImageChangedProc, imPtr);
 	    if (imPtr->tkImage == NULL) {
-		Tcl_AppendResult(interp, "can't find an image \"", 
-			imPtr->imageName, "\"", (char *)NULL);
 		Blt_Free(imPtr->imageName);
 		imPtr->imageName = NULL;
 		return TCL_ERROR;
@@ -2496,6 +2503,9 @@ FreeImageMarker(graphPtr, markerPtr)
     if (imPtr->srcImage != NULL) {
 	Blt_FreeColorImage(imPtr->srcImage);
     }
+    if (imPtr->gc != NULL) {
+	Tk_FreeGC(graphPtr->display, imPtr->gc);
+    }
 }
 
 /*
@@ -3749,11 +3759,11 @@ PointInPolygonMarker(markerPtr, samplePt
 {
     PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
 
-    if (pmPtr->nWorldPts < 2) {
-	return FALSE;
+    if ((pmPtr->nWorldPts >= 3) && (pmPtr->screenPts != NULL)) {
+	return Blt_PointInPolygon(samplePtr, pmPtr->screenPts, 
+		  pmPtr->nWorldPts + 1);
     }
-    return Blt_PointInPolygon(samplePtr, pmPtr->screenPts, 
-	pmPtr->nWorldPts + 1);
+    return FALSE;
 }
 
 /*
@@ -3771,7 +3781,7 @@ RegionInPolygonMarker(markerPtr, extsPtr
 {
     PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
     
-    if (pmPtr->nWorldPts >= 3) {
+    if ((pmPtr->nWorldPts >= 3) && (pmPtr->screenPts != NULL)) {
 	return Blt_RegionInPolygon(extsPtr, pmPtr->screenPts, pmPtr->nWorldPts,
 	       enclosed);
     }
@@ -4038,6 +4048,9 @@ FreePolygonMarker(graphPtr, markerPtr)
     if (pmPtr->outlinePts != NULL) {
 	Blt_Free(pmPtr->outlinePts);
     }
+    if (pmPtr->screenPts != NULL) {
+	Blt_Free(pmPtr->screenPts);
+    }
     Blt_FreeColorPair(&pmPtr->outline);
     Blt_FreeColorPair(&pmPtr->fill);
 }
@@ -4262,6 +4275,7 @@ ConfigureOp(graphPtr, interp, argc, argv
     int nNames, nOpts;
     char **options;
     register int i;
+    int under;
 
     /* Figure out where the option value pairs begin */
     argc -= 3;
@@ -4291,6 +4305,7 @@ ConfigureOp(graphPtr, interp, argc, argv
 	}
 	/* Save the old marker. */
 	oldName = markerPtr->name;
+	under = markerPtr->drawUnder;
 	if (Tk_ConfigureWidget(interp, graphPtr->tkwin, 
 		markerPtr->classPtr->configSpecs, nOpts, options, 
 		(char *)markerPtr, flags) != TCL_OK) {
@@ -4306,6 +4321,9 @@ ConfigureOp(graphPtr, interp, argc, argv
 	if ((*markerPtr->classPtr->configProc) (markerPtr) != TCL_OK) {
 	    return TCL_ERROR;
 	}
+	if (markerPtr->drawUnder != under) {
+	    graphPtr->flags |= REDRAW_BACKING_STORE;
+	}
     }
     return TCL_OK;
 }
@@ -4944,7 +4962,14 @@ Blt_NearestMarker(graphPtr, x, y, under)
     for (linkPtr = Blt_ChainLastLink(graphPtr->markers.displayList);
 	linkPtr != NULL; linkPtr = Blt_ChainPrevLink(linkPtr)) {
 	markerPtr = Blt_ChainGetValue(linkPtr);
+	/* 
+	 * Don't consider markers that are pending to be mapped. Even
+	 * if the marker has already been mapped, the coordinates
+	 * could be invalid now.  Better to pick no marker than the
+	 * wrong marker.
+	 */
 	if ((markerPtr->drawUnder == under) && (markerPtr->nWorldPts > 0) && 
+	    ((markerPtr->flags & MAP_ITEM) == 0) && 
 	    (!markerPtr->hidden) && (markerPtr->state == STATE_NORMAL)) {
 	    if ((*markerPtr->classPtr->pointProc) (markerPtr, &point)) {
 		return markerPtr;
--- blt-2.4z.orig/src/bltGrElem.c
+++ blt-2.4z/src/bltGrElem.c
@@ -1215,9 +1215,7 @@ RebuildDisplayList(graphPtr, newList)
 {
     int nNames;			/* Number of names found in Tcl name list */
     char **nameArr;		/* Broken out array of element names */
-    Blt_HashSearch cursor;
     register int i;
-    register Blt_HashEntry *hPtr;
     Element *elemPtr;		/* Element information record */
 
     if (Tcl_SplitList(graphPtr->interp, newList, &nNames, &nameArr) != TCL_OK) {
@@ -1227,17 +1225,11 @@ RebuildDisplayList(graphPtr, newList)
     }
     /* Clear the display list and mark all elements as hidden.  */
     Blt_ChainReset(graphPtr->elements.displayList);
-    for (hPtr = Blt_FirstHashEntry(&graphPtr->elements.table, &cursor);
-	hPtr != NULL; hPtr = Blt_NextHashEntry(&cursor)) {
-	elemPtr = (Element *)Blt_GetHashValue(hPtr);
-	elemPtr->hidden = TRUE;
-    }
 
     /* Rebuild the display list, checking that each name it exists
      * (currently ignoring invalid element names).  */
     for (i = 0; i < nNames; i++) {
 	if (NameToElement(graphPtr, nameArr[i], &elemPtr) == TCL_OK) {
-	    elemPtr->hidden = FALSE;
 	    Blt_ChainAppend(graphPtr->elements.displayList, elemPtr);
 	}
     }
@@ -1399,8 +1391,7 @@ Blt_ElementsToPostScript(graphPtr, psTok
 	    /* Comment the PostScript to indicate the start of the element */
 	    Blt_FormatToPostScript(psToken, "\n%% Element \"%s\"\n\n", 
 		elemPtr->name);
-	    (*elemPtr->procsPtr->printNormalProc) (graphPtr, psToken, 
-		elemPtr);
+	    (*elemPtr->procsPtr->printNormalProc) (graphPtr, psToken, elemPtr);
 	}
     }
 }
@@ -1426,8 +1417,7 @@ Blt_ActiveElementsToPostScript(graphPtr,
 	if ((!elemPtr->hidden) && (elemPtr->flags & ELEM_ACTIVE)) {
 	    Blt_FormatToPostScript(psToken, "\n%% Active Element \"%s\"\n\n",
 		elemPtr->name);
-	    (*elemPtr->procsPtr->printActiveProc) (graphPtr, psToken, 
-						   elemPtr);
+	    (*elemPtr->procsPtr->printActiveProc) (graphPtr, psToken, elemPtr);
 	}
     }
 }
@@ -1671,6 +1661,7 @@ ClosestOp(graphPtr, interp, argc, argv)
     ClosestSearch search;
     int i, x, y;
     int flags = TCL_LEAVE_ERR_MSG;
+    int found;
 
     if (graphPtr->flags & RESET_AXES) {
 	Blt_ResetAxes(graphPtr);
@@ -1715,13 +1706,23 @@ ClosestOp(graphPtr, interp, argc, argv)
     search.dist = (double)(search.halo + 1);
 
     if (i < argc) {
+	Blt_ChainLink *linkPtr;
+
 	for ( /* empty */ ; i < argc; i++) {
 	    if (NameToElement(graphPtr, argv[i], &elemPtr) != TCL_OK) {
 		return TCL_ERROR;	/* Can't find named element */
 	    }
-	    if (elemPtr->hidden) {
+	    found = FALSE;
+	    for (linkPtr = Blt_ChainFirstLink(graphPtr->elements.displayList);
+		 linkPtr == NULL; linkPtr = Blt_ChainNextLink(linkPtr)) {
+		if (elemPtr == Blt_ChainGetValue(linkPtr)) {
+		    found = TRUE;
+		    break;
+		}
+	    }
+	    if ((!found) || (elemPtr->hidden)) {
 		Tcl_AppendResult(interp, "element \"", argv[i], "\" is hidden",
-		    (char *)NULL);
+			(char *)NULL);
 		return TCL_ERROR;	/* Element isn't visible */
 	    }
 	    /* Check if the X or Y vectors have notifications pending */
@@ -1744,16 +1745,14 @@ ClosestOp(graphPtr, interp, argc, argv)
 	for (linkPtr = Blt_ChainLastLink(graphPtr->elements.displayList);
 	    linkPtr != NULL; linkPtr = Blt_ChainPrevLink(linkPtr)) {
 	    elemPtr = Blt_ChainGetValue(linkPtr);
-
 	    /* Check if the X or Y vectors have notifications pending */
-	    if ((elemPtr->flags & MAP_ITEM) ||
+	    if ((elemPtr->hidden) || 
+		(elemPtr->flags & MAP_ITEM) ||
 		(Blt_VectorNotifyPending(elemPtr->x.clientId)) ||
 		(Blt_VectorNotifyPending(elemPtr->y.clientId))) {
 		continue;
 	    }
-	    if (!elemPtr->hidden) {
-		(*elemPtr->procsPtr->closestProc) (graphPtr, elemPtr, &search);
-	    }
+	    (*elemPtr->procsPtr->closestProc)(graphPtr, elemPtr, &search);
 	}
 
     }
@@ -1859,30 +1858,6 @@ ConfigureOp(graphPtr, interp, argc, argv
 	    return TCL_ERROR;	/* Failed to configure element */
 	}
 	if (Blt_ConfigModified(elemPtr->specsPtr, "-hide", (char *)NULL)) {
-	    Blt_ChainLink *linkPtr;
-
-	    for (linkPtr = Blt_ChainFirstLink(graphPtr->elements.displayList);
-		linkPtr != NULL; linkPtr = Blt_ChainNextLink(linkPtr)) {
-		if (elemPtr == Blt_ChainGetValue(linkPtr)) {
-		    break;
-		}
-	    }
-	    if ((elemPtr->hidden) != (linkPtr == NULL)) {
-
-		/* The element's "hidden" variable is out of sync with
-		 * the display list. [That's what you get for having
-		 * two ways to do the same thing.]  This affects what
-		 * elements are considered for axis ranges and
-		 * displayed in the legend. Update the display list by
-		 * either by adding or removing the element.  */
-
-		if (linkPtr == NULL) {
-		    Blt_ChainPrepend(graphPtr->elements.displayList, elemPtr);
-		} else {
-		    Blt_ChainDeleteLink(graphPtr->elements.displayList, 
-					linkPtr);
-		}
-	    }
 	    graphPtr->flags |= RESET_AXES;
 	    elemPtr->flags |= MAP_ITEM;
 	}
