src/hg/lib/customTrack.c 1.181

1.181 2010/05/11 01:43:29 kent
Refactoring to split the trackDb.tableName field into separate track and table fields. Similarly track.mapName field goes to the same track and table fields.
Index: src/hg/lib/customTrack.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/customTrack.c,v
retrieving revision 1.180
retrieving revision 1.181
diff -b -B -U 4 -r1.180 -r1.181
--- src/hg/lib/customTrack.c	11 Dec 2009 15:32:47 -0000	1.180
+++ src/hg/lib/customTrack.c	11 May 2010 01:43:29 -0000	1.181
@@ -48,9 +48,10 @@
 AllocVar(tdb);
 tdb->shortLabel = cloneString(CT_DEFAULT_TRACK_NAME);
 tdb->longLabel = cloneString(CT_DEFAULT_TRACK_DESCR);
 
-tdb->tableName = customTrackTableFromLabel(tdb->shortLabel);
+tdb->table = customTrackTableFromLabel(tdb->shortLabel);
+tdb->track = cloneString(tdb->table);
 tdb->visibility = tvDense;
 tdb->grp = cloneString("user");
 tdb->type = (char *)NULL;
 tdb->canPack = 2;       /* unknown -- fill in later when type is known */
@@ -330,11 +331,13 @@
 safef(buf, sizeof(buf), "%s %d", prev, ct_nextDefaultTrackNum);
 ct->tdb->longLabel = cloneString(buf);
 freeMem(prev);
 
-prev = ct->tdb->tableName;
-ct->tdb->tableName = customTrackTableFromLabel(ct->tdb->shortLabel);
-freeMem(prev);
+freez(&ct->tdb->table);
+ct->tdb->table = customTrackTableFromLabel(ct->tdb->shortLabel);
+
+freez(&ct->tdb->track);
+ct->tdb->track = cloneString(ct->tdb->table);
 }
 
 struct customTrack *customTrackAddToList(struct customTrack *ctList,
                                          struct customTrack *addCts,
@@ -355,31 +358,31 @@
 slReverse(&addCts);
 for (ct = addCts; ct != NULL; ct = nextCt)
     {
     nextCt = ct->next;
-    if (hashLookup(ctHash, ct->tdb->tableName))
+    if (hashLookup(ctHash, ct->tdb->track))
         freeMem(ct);
     else
         {
         if (isDefaultTrack(ct) && makeDefaultUnique)
             makeUniqueDefaultTrack(ct);
         slAddHead(&newCtList, ct);
-        hashAdd(ctHash, ct->tdb->tableName, ct);
+        hashAdd(ctHash, ct->tdb->track, ct);
         }
     }
 /* add in older tracks that haven't been replaced by newer */
 for (ct = ctList; ct != NULL; ct = nextCt)
     {
     struct customTrack *newCt;
     nextCt = ct->next;
-    if ((newCt = hashFindVal(ctHash, ct->tdb->tableName)) != NULL)
+    if ((newCt = hashFindVal(ctHash, ct->tdb->track)) != NULL)
         {
         slAddHead(&replacedCts, ct);
         }
     else
         {
         slAddHead(&oldCtList, ct);
-        hashAdd(ctHash, ct->tdb->tableName, ct);
+        hashAdd(ctHash, ct->tdb->track, ct);
         }
     }
 slReverse(&oldCtList);
 slReverse(&replacedCts);
@@ -826,9 +829,9 @@
         {
         for (ct = ctList; ct != NULL; ct = nextCt)
             {
             nextCt = ct->next;
-            if (sameString(selectedTable, ct->tdb->tableName))
+            if (sameString(selectedTable, ct->tdb->track))
                 {
                 if (cartVarExists(cart, CT_DO_REMOVE_VAR))
                     {
                     /* remove a track if requested, e.g. by hgTrackUi */
@@ -965,9 +968,9 @@
 /* Find named custom track. */
 {
 struct customTrack *ct;
 for (ct=ctList;
-     ct != NULL && differentString(ct->tdb->tableName,name);
+     ct != NULL && differentString(ct->tdb->track,name);
      ct=ct->next) {}
 return ct;
 }