c462aa3843e20d6e149121fd630bb5f8d8023921
galt
  Wed Nov 5 17:19:14 2025 -0800
Need to have customTrack.c clear out this cart variable so it does not hang around and cause problems later. It was causing new autogenerated blat custom tracks to disappear after using hgTrackUi track and submittting. fixes #36660

diff --git src/hg/lib/customTrack.c src/hg/lib/customTrack.c
index 1dae331d906..480e38744f2 100644
--- src/hg/lib/customTrack.c
+++ src/hg/lib/customTrack.c
@@ -962,45 +962,45 @@
             {
             nextCt = ct->next;
             if (sameString(selectedTable, ct->tdb->track))
                 {
                 if (cartVarExists(cart, CT_DO_REMOVE_VAR))
                     {
                     /* remove a track if requested, e.g. by hgTrackUi */
                     removedCt = TRUE;
                     slRemoveEl(&ctList, ct);
                     /* remove visibility variable */
                     cartRemove(cart, selectedTable);
                     /* remove configuration variables */
                     char buf[128];
                     safef(buf, sizeof buf, "%s.", selectedTable);
                     cartRemovePrefix(cart, buf);
-                    /* remove control variables */
                     cartRemove(cart, CT_DO_REMOVE_VAR);
                     }
                 else
                     {
                     if (html && differentString(html, ct->tdb->html))
                         {
                         ct->tdb->html = html;
                         changedCt = TRUE;
                         }
                     }
                 break;
                 }
             }
         }
+    cartRemove(cart, CT_DO_REMOVE_VAR);
     cartRemove(cart, CT_SELECTED_TABLE_VAR);
     }
 
 /* merge new and old tracks */
 numAdded = slCount(newCts);
 /* add delay even if numAdded==0 because that can be when the loading
  * of the custom tracks failed.  The try is worth the penalty.
  */
 if (numAdded > 0)
     {
     static int botCheckMult = 0;
     if (0 == botCheckMult)      // only on first time through here
 	{                       // default is 1 when not specified
 	char *val = cfgOptionDefault("customTracks.botCheckMult", "1");
         botCheckMult = sqlSigned(val);