7559014e16a1413623d48a4107040cf3d781cbfb braney Fri Feb 1 09:37:54 2019 -0800 a few tweaks in response to code review #22866 diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c index 50f4e3b..9d9e9b3 100644 --- src/hg/hgTracks/hgTracks.c +++ src/hg/hgTracks/hgTracks.c @@ -6823,61 +6823,61 @@ struct grp *grpList = NULL; if (cartOptionalString(cart, "hgt.trackNameFilter") == NULL) { // If a single track was asked for and it is from a hub, then it is already in trackList loadTrackHubs(&trackList, &grpList); } loadCustomTracks(&trackList); groupTracks( &trackList, pGroupList, grpList, vis); setSearchedTrackToPackOrFull(trackList); boolean hideTracks = cgiOptionalString( "hideTracks") != NULL; if (hideTracks) changeTrackVis(groupList, NULL, tvHide); // set all top-level tracks to hide /* Get visibility values if any from ui. */ struct hash *superTrackHash = newHash(5); // cache whether supertrack is hiding tracks or not +char buffer[4096]; for (track = trackList; track != NULL; track = track->next) { // deal with any supertracks we're seeing for the first time if (tdbIsSuperTrackChild(track->tdb)) { struct hashEl *hel = NULL; if ((hel = hashLookup(superTrackHash, track->tdb->parent->track)) == NULL) // we haven't seen this guy { // first deal with visibility of super track char *s = hideTracks ? cgiOptionalString(track->tdb->parent->track) : cartOptionalString(cart, track->tdb->parent->track); if (s) { track->tdb->parent->visibility = hTvFromString(s) ; cartSetString(cart, track->tdb->parent->track, s); } else if (startsWith("hub_", track->tdb->parent->track)) { - s = hideTracks ? cgiOptionalString( trackHubSkipHubName(track->tdb->parent->track)) : cgiOptionalString( trackHubSkipHubName(track->tdb->parent->track)); + s = hideTracks ? cgiOptionalString( trackHubSkipHubName(track->tdb->parent->track)) : cartOptionalString( cart, trackHubSkipHubName(track->tdb->parent->track)); if (s) { cartSetString(cart, track->tdb->parent->track, s); cartRemove(cart, trackHubSkipHubName(track->tdb->parent->track)); // remove the undecorated version track->tdb->parent->visibility = hTvFromString(s) ; } } // now look to see if we have a _sel statement to turn off all subtracks (including the current one) unsigned hideChildren = 0; - char buffer[4096]; char *usedThis = buffer; safef(buffer, sizeof buffer, "%s_sel", track->tdb->parent->track); s = cartOptionalString(cart, buffer); if (s == NULL && startsWith("hub_", track->tdb->parent->track)) s = cartOptionalString(cart, usedThis = trackHubSkipHubName(buffer)); if (s != NULL) { if (sameString(s, "0")) hideChildren = 1; cartRemove(cart, usedThis); // we don't want this hanging out in the cart } // mark this as having been addressed @@ -6911,64 +6911,62 @@ { // maybe this track is on the URL without the hub_ prefix if (startsWith("hub_", track->track)) s = cgiOptionalString(trackHubSkipHubName(track->track)); if (s != NULL && !track->limitedVisSet) { track->visibility = hTvFromString(s); cartSetString(cart, track->track, s); // add the decorated visibility to the cart cartRemove(cart, trackHubSkipHubName(track->track)); // remove the undecorated version } } // now deal with composite track children if (tdbIsComposite(track->tdb)) { - char buffer[4096]; char *usedThis = buffer; // first check to see if we've been asked to hide all the subtracks - boolean hideTracks = FALSE; + boolean hideChildren = FALSE; safef(buffer, sizeof buffer, "%s_sel", track->track); s = cartOptionalString(cart, buffer); if (s == NULL && startsWith("hub_", track->track)) s = cartOptionalString(cart, usedThis = trackHubSkipHubName(buffer)); if ((s != NULL) && (sameString(s, "0"))) - hideTracks = TRUE; + hideChildren = TRUE; cartRemove(cart, usedThis); // we don't want these _sel variables in the cart // now see if we have any specified visibilities struct track *subtrack; for (subtrack = track->subtracks; subtrack != NULL; subtrack = subtrack->next) { char *s = hideTracks ? cgiOptionalString( subtrack->track) : cartOptionalString(cart, subtrack->track); if (s == NULL && startsWith("hub_", subtrack->track)) s = hideTracks ? cgiOptionalString(trackHubSkipHubName(subtrack->track)) : cartOptionalString(cart, trackHubSkipHubName(subtrack->track)); - char buffer[4096]; safef(buffer, sizeof buffer, "%s_sel", subtrack->track); if (s != NULL) { subtrack->visibility = hTvFromString(s); cartSetString(cart, subtrack->track, s); if (sameString("hide", s)) cartSetString(cart, buffer, "0"); else cartSetString(cart, buffer, "1"); } - else if (hideTracks && isSubtrackVisible(subtrack)) + else if (hideChildren && isSubtrackVisible(subtrack)) cartSetString(cart, buffer, "0"); } } } return trackList; } char *collapseGroupVar(char *name) /* Construct cart variable name for collapsing group */ { static char varName[256]; safef(varName, sizeof(varName), "%s%s_%s_%s", "hgt", "group", name, "close"); return (cloneString(varName)); }