433ae984b2cf4153a3274c70ace83a11b3bee4f8
galt
  Thu Jan 7 16:18:02 2016 -0800
Fixing sub-issue # 107 in RM 12242, crashed if certain conditions caused vis changes during track-load. Work around for now is to just clone all tracks for all windows instead of only cloning non-hidden tracks.

diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c
index 8e028f1..e5766c8 100644
--- src/hg/hgTracks/hgTracks.c
+++ src/hg/hgTracks/hgTracks.c
@@ -7350,55 +7350,64 @@
 
 // NEED TO LOAD ALL WINDOWS NOW
 // 
 //   Need to load one window at a time!
 //
 //   The use of the global values for a window
 //   means that differerent threads cannot use different global window values.
 //   Threads must run on just one window value at a time.
 //
 //   Begin by making a copy of the track structure for visible tracks
 //   for all windows.
 
 
 //warn("copy track structures for multiple  windows"); // DEBUG REMOVE
 // COPY TRACK STRUCTURES for other windows.
+
+// TODO: due to an issue where some loading code is modifying the visibility
+// of subtracks from hide to visible, I am forced to remove the optimization
+// of cloning ONLY non-hidden tracks and subtracks.  If the offending code
+// can be identified and moved into a step proceding the track cloning,
+// then we can return to that optimization. 
+//	if (track->visibility != tvHide)
+//		if (subtrack->visibility != tvHide)
+
 windows->trackList = trackList;  // save current track list in window
 struct window *window;
 for (window=windows; window->next; window=window->next)
     {
     struct track *newTrackList = NULL;
     for (track = trackList; track != NULL; track = track->next)
 	{
 	track->nextWindow = NULL;
-	if (track->visibility != tvHide)
+	//if (track->visibility != tvHide)  // Unable to use this optimization at present
 	    {
 	    struct track *copy;
 	    AllocVar(copy);
 	    memmove(copy,track,sizeof(struct track));
 	    copy->next = NULL;
 	    copy->nextWindow = NULL;
 	    copy->prevWindow = track;
 	    slAddHead(&newTrackList, copy);
 	    track->nextWindow = copy;
 
 	    // copy subtracks.
 	    copy->subtracks = NULL;
 	    struct track *subtrack;
 	    for (subtrack = track->subtracks; subtrack != NULL; subtrack = subtrack->next)
 		{
-		if (subtrack->visibility != tvHide)
+		//if (subtrack->visibility != tvHide)  // Unable to use this optimization at present
 		    {
 		    struct track *subcopy;
 		    AllocVar(subcopy);
 		    memmove(subcopy,subtrack,sizeof(struct track));
 		    subcopy->next = NULL;
 		    subcopy->nextWindow = NULL;
 		    subcopy->prevWindow = subtrack;
 		    slAddHead(&copy->subtracks, subcopy);
 		    subtrack->nextWindow = subcopy;
 		    }
 		}
 	    slReverse(&copy->subtracks);
 	    //warn("%s track subs: %d  copy subs: %d", track->track, slCount(track->subtracks), slCount(copy->subtracks));
 	    }
 	}