Index: src/hg/hgTracks/bigBedTrack.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/bigBedTrack.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -b -B -U 4 -r1.3 -r1.4
--- src/hg/hgTracks/bigBedTrack.c	26 Jan 2010 20:11:27 -0000	1.3
+++ src/hg/hgTracks/bigBedTrack.c	6 Feb 2010 20:45:12 -0000	1.4
@@ -32,13 +32,8 @@
 /* Return list of intervals in range. */
 {
 struct bbiFile *bbi = track->bbiFile;
 int maxItems = maximumTrackItems(track) + 1;
-if (bbi == NULL)
-    {
-    char *fileName = bbiNameFromTable(conn, track->mapName);
-    bbi = track->bbiFile = bigBedFileOpen(fileName);
-    }
 struct bigBedInterval *result = bigBedIntervalQuery(bbi, chrom, start, end, maxItems, lm);
 if (slCount(result) >= maxItems)
     {
     track->limitedVis = tvDense;
@@ -135,5 +130,12 @@
                                 int wordCount, char *words[])
 /* Set up bigBed methods. */
 {
 complexBedMethods(track, tdb, TRUE, wordCount, words);
+if (track->bbiFile == NULL)
+    {
+    struct sqlConnection *conn = hAllocConn(database);
+    char *fileName = bbiNameFromTable(conn, track->mapName);
+    hFreeConn(&conn);
+    track->bbiFile = bigBedFileOpen(fileName);
+    }
 }

