88c3b3d8ed217d673a1879972d488f2303ea72f3
hiram
  Wed Jun 22 15:53:12 2011 -0700
properly recognize custom tracks, and allow close of bigWig files after load time
diff --git src/hg/hgTracks/wigTrack.c src/hg/hgTracks/wigTrack.c
index 10144ee..ba3faa0 100644
--- src/hg/hgTracks/wigTrack.c
+++ src/hg/hgTracks/wigTrack.c
@@ -418,31 +418,31 @@
  *	only those rows with Span >= 1000 to see if an appropriate zoom
  *	level exists.
  */
 int basesPerPixel = (int)((double)(winEnd - winStart)/(double)insideWidth);
 char *span1K = "Span >= 1000 limit 1";
 char *spanOver1K = "Span >= 1000";
 char whereSpan[SMALLBUF];
 int spanMinimum = 1;
 char *dbTableName = NULL;
 struct trackDb *tdb = NULL;
 int loadStart = winStart, loadEnd = winEnd;
 
 #ifndef GBROWSE
 struct customTrack *ct = NULL;
 /*	custom tracks have different database	*/
-if (tg->customPt != (void *)NULL)
+if (isCustomTrack(tg->table) && tg->customPt)
     {
     hFreeConn(&conn);
     conn = hAllocConn(CUSTOM_TRASH);
     ct = tg->customPt;
     dbTableName = ct->dbTableName;
     tdb = ct->tdb;
     }
 else
 #endif /* GBROWSE */
     {
     dbTableName = tg->table;
     tdb = tg->tdb;
     }
 
 /*	Allocate trackSpans one time only	*/
@@ -1067,31 +1067,31 @@
 	hvGfxLine(hvg,x1,y1,x2,y2,black);
 	}
 
     }	/*	drawing y= line marker	*/
 }	/*	drawArbitraryYLine()	*/
 
 void wigMapSelf(struct track *tg, struct hvGfx *hvg, int seqStart, int seqEnd,
     int xOff, int yOff, int width)
 /*	if self mapping, create the mapping box	*/
 {
 /*	Map this wiggle area if we are self mapping	*/
 if (tg->mapsSelf)
     {
     char *itemName;
 #ifndef GBROWSE
-    if (tg->customPt)
+    if (isCustomTrack(tg->table) && tg->customPt)
 	{
 	struct customTrack *ct = tg->customPt;
 	itemName = (char *)needMem(LARGEBUF * sizeof(char));
 	safef(itemName, LARGEBUF, "%s %s", ct->wigFile, tg->track);
 	}
     else
 #endif /* GBROWSE */
 	itemName = cloneString(tg->track);
 
     // Don't bother if we are imageV2 and a dense child.
     if(!theImgBox || tg->limitedVis != tvDense || !tdbIsCompositeChild(tg->tdb))
     mapBoxHc(hvg, seqStart, seqEnd, xOff, yOff, width, tg->height, tg->track,
             itemName, NULL);
     freeMem(itemName);
     }