f8d8ca673a50a4c0870e011d9d208cd85112bf89 braney Fri Apr 7 11:30:30 2023 -0700 some small tweaks to the recommended track set code (don't hide tracks that are hidden in the current session if they're specifically turned on in the RTS) diff --git src/hg/lib/cart.c src/hg/lib/cart.c index c845934..9745626 100644 --- src/hg/lib/cart.c +++ src/hg/lib/cart.c @@ -155,37 +155,48 @@ if (!sqlTableExists(conn, userDbTable())) { fprintf(stderr, "cartTablesOk failed on %s.%s pid=%ld\n", sqlGetDatabase(conn), userDbTable(), (long)getpid()); return FALSE; } if (!sqlTableExists(conn, sessionDbTable())) { fprintf(stderr, "cartTablesOk failed on %s.%s pid=%ld\n", sqlGetDatabase(conn), sessionDbTable(), (long)getpid()); return FALSE; } return TRUE; } -static void mergeHash(struct hash *first, struct hash *second) +static void mergeHash(struct hash *origHash, struct hash *overlayHash) /* Merge one hash on top of another. */ { -struct hashCookie cookie = hashFirst(second); -struct hashEl *hel; -while ((hel = hashNext(&cookie)) != NULL) - hashReplace(first, hel->name, hel->val); +struct hashCookie cookie = hashFirst(overlayHash); +struct hashEl *helOverlay; +while ((helOverlay = hashNext(&cookie)) != NULL) + { + char *varName = helOverlay->name; + struct hashEl *helOrig = hashLookup(origHash, varName); + if (helOrig) + { + // we don't want to hide a track that's visible in the overlay + if (differentString("hide", helOverlay->val)) + hashReplace(origHash, helOverlay->name, helOverlay->val); + } + else + hashAdd(origHash, varName, helOverlay->val); + } } static void loadHash(struct hash *hash, char *contents) /* Load a hash from a cart-like string. */ { char *namePt, *dataPt, *nextNamePt; namePt = contents; while (namePt != NULL && namePt[0] != 0) { dataPt = strchr(namePt, '='); if (dataPt == NULL) errAbort("Mangled input string %s", namePt); *dataPt++ = 0; nextNamePt = strchr(dataPt, '&'); if (nextNamePt == NULL)