Index: src/hg/hgTracks/bedTrack.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/bedTrack.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -b -B -U 4 -r1.18 -r1.19
--- src/hg/hgTracks/bedTrack.c	1 Nov 2009 19:46:03 -0000	1.18
+++ src/hg/hgTracks/bedTrack.c	10 Nov 2009 05:48:17 -0000	1.19
@@ -26,14 +26,15 @@
 struct bigBedInterval *bigBedSelectRange(struct sqlConnection *conn, struct track *track,
 	char *chrom, int start, int end, struct lm *lm)
 /* Return list of intervals in range. */
 {
-char *fileName = track->bbiFileName;
-if (fileName == NULL)
-    track->bbiFileName = fileName = bbiNameFromTable(conn, track->mapName);
-struct bbiFile *bbi = bigBedFileOpen(fileName);
+struct bbiFile *bbi = track->bbiFile;
+if (bbi == NULL)
+    {
+    char *fileName = bbiNameFromTable(conn, track->mapName);
+    bbi = track->bbiFile = bigBedFileOpen(fileName);
+    }
 struct bigBedInterval *result = bigBedIntervalQuery(bbi, chrom, start, end, 0, lm);
-bbiFileClose(&bbi);
 return result;
 }
 
 struct bed *bedLoadPairedTagAlign(char **row)

