diff -cr blt/src/bltGrMarker.c /Users/hayes/dev-cvs-nightly/slicer2/Lib/darwin-ppc/tcl/blt/src/bltGrMarker.c
*** blt/src/bltGrMarker.c	Fri May  6 12:07:07 2005
--- /Users/hayes/dev-cvs-nightly/slicer2/Lib/darwin-ppc/tcl/blt/src/bltGrMarker.c	Fri Nov 11 14:24:45 2005
***************
*** 29,34 ****
--- 29,37 ----
  #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,818 ****
  
      /* Polygon specific attributes and fields */
  
!     Point2D *screenPts;
  
      ColorPair outline;
      ColorPair fill;
--- 815,827 ----
  
      /* Polygon specific attributes and fields */
  
!     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;
***************
*** 1563,1571 ****
      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;
--- 1572,1577 ----
***************
*** 1650,1658 ****
      if (bmPtr->srcBitmap == None) {
  	return;
      }
!     if (bmPtr->destBitmap != bmPtr->srcBitmap) {
  	Tk_FreePixmap(graphPtr->display, bmPtr->destBitmap);
! 	bmPtr->destBitmap = bmPtr->srcBitmap;
      }
      /* 
       * Collect the coordinates.  The number of coordinates will determine
--- 1656,1664 ----
      if (bmPtr->srcBitmap == None) {
  	return;
      }
!     if (bmPtr->destBitmap != None) {
  	Tk_FreePixmap(graphPtr->display, bmPtr->destBitmap);
! 	bmPtr->destBitmap = None;
      }
      /* 
       * Collect the coordinates.  The number of coordinates will determine
***************
*** 1752,1758 ****
      } else {
  	bmPtr->destWidth = srcWidth;
  	bmPtr->destHeight = srcHeight;
! 	bmPtr->destBitmap = bmPtr->srcBitmap;
      }
      bmPtr->anchorPos = anchorPos;
      {
--- 1758,1764 ----
      } else {
  	bmPtr->destWidth = srcWidth;
  	bmPtr->destHeight = srcHeight;
! 	bmPtr->destBitmap = None;
      }
      bmPtr->anchorPos = anchorPos;
      {
***************
*** 1909,1917 ****
      Graph *graphPtr = markerPtr->graphPtr;
      BitmapMarker *bmPtr = (BitmapMarker *)markerPtr;
      double theta;
  
!     if ((bmPtr->destBitmap == None) || (bmPtr->destWidth < 1) || 
! 	(bmPtr->destHeight < 1)) {
  	return;
      }
      theta = FMOD(bmPtr->theta, (double)90.0);
--- 1915,1924 ----
      Graph *graphPtr = markerPtr->graphPtr;
      BitmapMarker *bmPtr = (BitmapMarker *)markerPtr;
      double theta;
+     Pixmap bitmap;
  
!     bitmap = GETBITMAP(bmPtr);
!     if ((bitmap == None) || (bmPtr->destWidth < 1) || (bmPtr->destHeight < 1)) {
  	return;
      }
      theta = FMOD(bmPtr->theta, (double)90.0);
***************
*** 1934,1947 ****
  	    XFillPolygon(graphPtr->display, drawable, bmPtr->fillGC,
  		 polygon, bmPtr->nOutlinePts, Convex, CoordModeOrigin);
  	}
! 	XSetClipMask(graphPtr->display, bmPtr->gc, bmPtr->destBitmap);
  	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,
  	bmPtr->destWidth, bmPtr->destHeight, (int)bmPtr->anchorPos.x, 
  	(int)bmPtr->anchorPos.y, 1);
  }
--- 1941,1954 ----
  	    XFillPolygon(graphPtr->display, drawable, bmPtr->fillGC,
  		 polygon, bmPtr->nOutlinePts, Convex, CoordModeOrigin);
  	}
! 	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, bitmap, drawable, bmPtr->gc, 0, 0,
  	bmPtr->destWidth, bmPtr->destHeight, (int)bmPtr->anchorPos.x, 
  	(int)bmPtr->anchorPos.y, 1);
  }
***************
*** 1965,1972 ****
  {
      Graph *graphPtr = markerPtr->graphPtr;
      BitmapMarker *bmPtr = (BitmapMarker *)markerPtr;
  
!     if (bmPtr->destBitmap == None) {
  	return;
      }
      if (bmPtr->fillColor != NULL) {
--- 1972,1981 ----
  {
      Graph *graphPtr = markerPtr->graphPtr;
      BitmapMarker *bmPtr = (BitmapMarker *)markerPtr;
+     Pixmap bitmap;
  
!     bitmap = GETBITMAP(bmPtr);
!     if (bitmap == None) {
  	return;
      }
      if (bmPtr->fillColor != NULL) {
***************
*** 1982,1988 ****
      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,
  	bmPtr->destWidth, bmPtr->destHeight);
      Blt_AppendToPostScript(psToken, "    } imagemask\n",
  	"grestore\n", (char *)NULL);
--- 1991,1997 ----
      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, bitmap,
  	bmPtr->destWidth, bmPtr->destHeight);
      Blt_AppendToPostScript(psToken, "    } imagemask\n",
  	"grestore\n", (char *)NULL);
***************
*** 2018,2024 ****
      if (bmPtr->fillGC != NULL) {
  	Tk_FreeGC(graphPtr->display, bmPtr->fillGC);
      }
!     if (bmPtr->destBitmap != bmPtr->srcBitmap) {
  	Tk_FreePixmap(graphPtr->display, bmPtr->destBitmap);
      }
  }
--- 2027,2033 ----
      if (bmPtr->fillGC != NULL) {
  	Tk_FreeGC(graphPtr->display, bmPtr->fillGC);
      }
!     if (bmPtr->destBitmap != None) {
  	Tk_FreePixmap(graphPtr->display, bmPtr->destBitmap);
      }
  }
***************
*** 2127,2134 ****
  	    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;
--- 2136,2141 ----
***************
*** 2494,2499 ****
--- 2501,2509 ----
      if (imPtr->srcImage != NULL) {
  	Blt_FreeColorImage(imPtr->srcImage);
      }
+     if (imPtr->gc != NULL) {
+ 	Tk_FreeGC(graphPtr->display, imPtr->gc);
+     }
  }
  
  /*
***************
*** 3747,3757 ****
  {
      PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
  
!     if (pmPtr->nWorldPts < 2) {
! 	return FALSE;
      }
!     return Blt_PointInPolygon(samplePtr, pmPtr->screenPts, 
! 	pmPtr->nWorldPts + 1);
  }
  
  /*
--- 3757,3767 ----
  {
      PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
  
!     if ((pmPtr->nWorldPts >= 3) && (pmPtr->screenPts != NULL)) {
! 	return Blt_PointInPolygon(samplePtr, pmPtr->screenPts, 
! 		  pmPtr->nWorldPts + 1);
      }
!     return FALSE;
  }
  
  /*
***************
*** 3769,3775 ****
  {
      PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
      
!     if (pmPtr->nWorldPts >= 3) {
  	return Blt_RegionInPolygon(extsPtr, pmPtr->screenPts, pmPtr->nWorldPts,
  	       enclosed);
      }
--- 3779,3785 ----
  {
      PolygonMarker *pmPtr = (PolygonMarker *)markerPtr;
      
!     if ((pmPtr->nWorldPts >= 3) && (pmPtr->screenPts != NULL)) {
  	return Blt_RegionInPolygon(extsPtr, pmPtr->screenPts, pmPtr->nWorldPts,
  	       enclosed);
      }
***************
*** 4036,4041 ****
--- 4046,4054 ----
      if (pmPtr->outlinePts != NULL) {
  	Blt_Free(pmPtr->outlinePts);
      }
+     if (pmPtr->screenPts != NULL) {
+ 	Blt_Free(pmPtr->screenPts);
+     }
      Blt_FreeColorPair(&pmPtr->outline);
      Blt_FreeColorPair(&pmPtr->fill);
  }
***************
*** 4260,4265 ****
--- 4273,4279 ----
      int nNames, nOpts;
      char **options;
      register int i;
+     int under;
  
      /* Figure out where the option value pairs begin */
      argc -= 3;
***************
*** 4289,4294 ****
--- 4303,4309 ----
  	}
  	/* 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) {
***************
*** 4304,4309 ****
--- 4319,4327 ----
  	if ((*markerPtr->classPtr->configProc) (markerPtr) != TCL_OK) {
  	    return TCL_ERROR;
  	}
+ 	if (markerPtr->drawUnder != under) {
+ 	    graphPtr->flags |= REDRAW_BACKING_STORE;
+ 	}
      }
      return TCL_OK;
  }
***************
*** 4942,4948 ****
--- 4960,4973 ----
      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;
diff -cr blt/src/bltTreeView.c /Users/hayes/dev-cvs-nightly/slicer2/Lib/darwin-ppc/tcl/blt/src/bltTreeView.c
*** blt/src/bltTreeView.c	Fri May  6 12:07:07 2005
--- /Users/hayes/dev-cvs-nightly/slicer2/Lib/darwin-ppc/tcl/blt/src/bltTreeView.c	Fri Nov 11 14:25:02 2005
***************
*** 3866,3871 ****
--- 3866,3872 ----
  	assert(tvPtr->visibleArr);
      }
      tvPtr->nVisible = 0;
+     tvPtr->visibleArr[0] = NULL;
  
      if (tvPtr->rootPtr->flags & ENTRY_HIDDEN) {
  	return TCL_OK;		/* Root node is hidden. */
***************
*** 4631,4636 ****
--- 4632,4640 ----
      int width;
      int x0, cx, xOffset;
  
+     if (tvPtr->titleHeight < 1) {
+ 	return;
+     }
      columnWidth = columnPtr->width;
      cx = x;
      if (columnPtr->position == Blt_ChainGetLength(tvPtr->colChainPtr)) {
diff -cr blt/src/shared/Makefile.in /Users/hayes/dev-cvs-nightly/slicer2/Lib/darwin-ppc/tcl/blt/src/shared/Makefile.in
*** blt/src/shared/Makefile.in	Fri May  6 12:07:07 2005
--- /Users/hayes/dev-cvs-nightly/slicer2/Lib/darwin-ppc/tcl/blt/src/shared/Makefile.in	Fri Nov 11 14:25:42 2005
***************
*** 18,24 ****
  SHLIB_TCL_ONLY_LIB_SPECS = @SHLIB_TCL_ONLY_LIB_SPECS@ 
  SHLIB_LIB_SPECS = @SHLIB_LIB_SPECS@ 
  SHLIB_LD =	@SHLIB_LD@
! LDFLAGS =	@LDFLAGS@ @LD_RUN_PATH@
  
  prefix =	@prefix@
  exec_prefix =	@exec_prefix@
--- 18,24 ----
  SHLIB_TCL_ONLY_LIB_SPECS = @SHLIB_TCL_ONLY_LIB_SPECS@ 
  SHLIB_LIB_SPECS = @SHLIB_LIB_SPECS@ 
  SHLIB_LD =	@SHLIB_LD@
! LDFLAGS =	@LDFLAGS@ @LD_RUN_PATH@ $(LIBS)
  
  prefix =	@prefix@
  exec_prefix =	@exec_prefix@
