3088a3645d56423f6a898c57d80d1ec56a72f17f
angie
  Fri Aug 29 12:46:11 2014 -0700
In doOutHyperlinks, no attempt was made to find a tdb for table2 whenintersecting, but we can find it for cheap in fullTrackList.
Meanwhile, passing NULL into ensureVisibility caused a call to
hTrackDbForTrackAndAncestors which doesn't work for custom tracks
anyway (and used to SEGV when given a custom track).  Thanks Matt for finding!
refs #13776

diff --git src/hg/hgTables/hgTables.c src/hg/hgTables/hgTables.c
index 1b13cef..d71d50c 100644
--- src/hg/hgTables/hgTables.c
+++ src/hg/hgTables/hgTables.c
@@ -1572,31 +1572,34 @@
         int end = min(hChromSize(database, bed->chrom),bed->chromEnd+outputPad);
 	safef(posBuf, sizeof(posBuf), "%s:%d-%d",
 		    bed->chrom, start, end);
 	/* Construct browser anchor URL with tracks we're looking at open. */
         if (doGalaxy())
             {
             char *s, *script = hgTracksName();
             s = strstr(script, "cgi-bin");
             hPrintf("<A HREF=\"http://%s/%s?db=%s", cgiServerNamePort(), s, database);
             }
         else
 	    hPrintf("<A HREF=\"%s?db=%s", hgTracksName(), database);
 	hPrintf("&position=%s", posBuf);
 	ensureVisibility(database, table, curTrack);
 	if (table2 != NULL)
-	    ensureVisibility(database, table2, NULL);
+            {
+            struct trackDb *tdb2 = findTrack(table2, fullTrackList);
+            ensureVisibility(database, table2, tdb2);
+            }
 	hPrintf("\" TARGET=_blank>");
 	name = bed->name;
 	if (bed->name == NULL)
 	    name = posBuf;
 	if (sameString(name, posBuf))
 	    hPrintf("%s", posBuf);
 	else
 	    {
 	    char *tmp = htmlEncode(name);
 	    hPrintf("%s at %s", tmp, posBuf);
 	    freeMem(tmp);
 	    }
 	hPrintf("</A><BR>\n");
 	++count;
 	}