b5972d8ddeddbca1b26e0f295c9325a23fbe6f40
tdreszer
  Fri Sep 17 16:40:14 2010 -0700
SuperTracks may have superpowers, but still should avoiding cloning kids.
diff --git src/hg/lib/trackDbCustom.c src/hg/lib/trackDbCustom.c
index 25688ed..9af8268 100644
--- src/hg/lib/trackDbCustom.c
+++ src/hg/lib/trackDbCustom.c
@@ -475,12 +475,15 @@
  * supertrack. */
 {
 struct superTrackInfo *stInfo = getSuperTrackInfo(tdb);
+if(stInfo == NULL || stInfo->isSuper)
+    return;
 tdb->parentName = cloneString(stInfo->parentName);
 tdb->visibility = stInfo->defaultVis;
 tdbMarkAsSuperTrackChild(tdb);
 if(tdb->parent)
     {
     tdbMarkAsSuperTrack(tdb->parent);
+    refAddUnique(&(tdb->parent->children),tdb);
     }
 freeMem(stInfo);
 }
@@ -504,6 +507,7 @@
         tdb->isShow = stInfo->isShow;
         if (!hashLookup(superHash, tdb->track))
             hashAdd(superHash, tdb->track, tdb);
+        tdb->children = NULL; // assertable?
         }
     freeMem(stInfo);
     }
@@ -812,32 +816,15 @@
 /* Do superTrack inheritance.  This involves setting up the parent pointers to superTracks,
  * but removing the superTracks themselves from the list. */
 struct trackDb *superlessList = NULL;
+trackDbSuperMarkup(tdbList);
 for (tdb = tdbList; tdb != NULL; tdb = next)
     {
     next = tdb->next;
-    char *superTrack = trackDbSetting(tdb, "superTrack");
-    if (superTrack != NULL)
-        {
-	if (startsWithWord("on", superTrack))
-	    {
+    if (tdbIsSuperTrack(tdb))
 	    tdb->next = NULL;
-	    }
-	else
-	    {
-	    char *parentName = tdb->parentName = cloneFirstWord(superTrack);
-	    struct trackDb *parent = hashFindVal(trackHash, parentName);
-	    if (parent == NULL)
-		errAbort("Parent track %s of supertrack %s doesn't exist",
-			parentName, tdb->track);
-	    tdb->parent = parent;
-	    slAddHead(&superlessList, tdb);
-	    }
-	}
     else
-        {
 	slAddHead(&superlessList, tdb);
 	}
-    }
 
 /* Do subtrack hierarchy - filling in parent and subtracks fields. */
 for (tdb = superlessList; tdb != NULL; tdb = next)