src/hg/hgTables/compositeTrack.c 1.14
1.14 2009/04/10 20:04:28 tdreszer
Fix many instances of using composite tdb when subtrack tdb is needed
Index: src/hg/hgTables/compositeTrack.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTables/compositeTrack.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -b -B -U 4 -r1.13 -r1.14
--- src/hg/hgTables/compositeTrack.c 13 Mar 2009 21:40:33 -0000 1.13
+++ src/hg/hgTables/compositeTrack.c 10 Apr 2009 20:04:28 -0000 1.14
@@ -148,27 +148,39 @@
printf("Base-pair-wise union (OR) of %s and other selected subtracks<P>\n",
curTable);
}
-static struct trackDb *getPrimaryTdb()
-/* Return a pointer to the subtrack tdb for the primary subtrack. */
+struct trackDb *findTdbForTable(char *db,struct trackDb *parent,char *table)
+/* Find or creates the tdb for this table. */
{
-struct trackDb *primary = NULL, *sTdb = NULL;
-for (sTdb = curTrack->subtracks; sTdb != NULL; sTdb = sTdb->next)
- {
- if (sameString(curTable, sTdb->tableName))
- {
- primary = sTdb;
- break;
+if(isEmpty(table))
+ return parent;
+struct trackDb *tdb = NULL;
+if (isCustomTrack(table))
+ {
+ struct customTrack *ct = lookupCt(table);
+ if (ct != NULL)
+ tdb = ct->tdb;
}
- }
-return primary;
+else
+ tdb = tdbFindOrCreate(db,parent,table);
+return tdb;
}
+char *findTypeForTable(char *db,struct trackDb *parent,char *table)
+/* Finds the TrackType for this Table */
+{
+struct trackDb *tdb = findTdbForTable(db,parent,table);
+if(tdb)
+ return tdb->type;
+return (parent?parent->type:NULL);
+}
+
+
void doSubtrackMergeMore(struct sqlConnection *conn)
/* Respond to subtrack merge create/edit button */
{
-struct trackDb *primary = getPrimaryTdb();
+struct trackDb *primary = subTdbFind(curTrack,curTable);
char *dbTable = getDbTable(database, curTable);
htmlOpen("Merge subtracks of %s (%s)",
curTrack->tableName, curTrack->longLabel);
@@ -205,9 +217,9 @@
/* Return a multi-line string that describes the specified subtrack merge,
* with each line beginning with linePrefix. */
{
struct dyString *dy = dyStringNew(512);
-struct trackDb *primary = getPrimaryTdb(), *tdb = NULL;
+struct trackDb *primary = subTdbFind(curTrack,curTable), *tdb = NULL;
dyStringAppend(dy, linePrefix);
dyStringPrintf(dy, "Subtrack merge, primary table = %s (%s)\n",
curTable, primary->longLabel);
dyStringAppend(dy, linePrefix);