36710988224ab9373893a97a6edc95e033b0d646
braney
  Fri Oct 18 08:52:28 2024 -0700
density mode on vcf tracks was crashing.  Refs #34659

diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c
index 8507469..914d456 100644
--- src/hg/hgTracks/simpleTracks.c
+++ src/hg/hgTracks/simpleTracks.c
@@ -843,47 +843,33 @@
 /* Return the maximum number of items to allow overflow indication. */
 {
 int answer = maxItemsToUseOverflowDefault;
 char *maxItemsString = trackDbSetting(tg->tdb, "maxItemsToOverflow");
 if (maxItemsString != NULL)
     answer = sqlUnsigned(maxItemsString);
 
 return answer;
 }
 
 int tgFixedTotalHeightOptionalOverflow(struct track *tg, enum trackVisibility vis,
                                        int lineHeight, int heightPer, boolean allowOverflow)
 /* Most fixed height track groups will use this to figure out the height
  * they use. */
 {
-
-boolean doWiggle = checkIfWiggling(cart, tg);
-if (doWiggle)
-    {
-    struct wigCartOptions *wigCart = tg->wigCartData;
-    if (tg->wigCartData == NULL)
-	{
-        // fake the trackDb range for this auto-wiggle
-        int wordCount = 3;
-        char *words[3];
-        words[0] = "bedGraph";
-	wigCart = wigCartOptionsNew(cart, tg->tdb, wordCount, words );
-        wigCart->windowingFunction = wiggleWindowingMean;
-	tg->wigCartData = (void *) wigCart;
-	}
-    return wigTotalHeight(tg, vis);
-    }
+int height;
+if ((height = setupForWiggle(tg, vis)) != 0)
+    return height;
 
 int rows;
 double maxHeight = maximumTrackHeight(tg);
 int itemCount = slCount(tg->items);
 int maxItemsToUseOverflow = maxItemsToOverflow(tg);
 tg->heightPer = heightPer;
 tg->lineHeight = lineHeight;
 
 /* Note that the maxCount variable passed to packCountRowsOverflow()
    is tied to the maximum height allowed for a track and influences
    decisions about when to squish, dense, or overflow a track.
 
    If doing overflow try to pack all the items into the maxHeight area
    or put all the overflow into the last row. If not doing overflow
    allow the track enough rows to go over the maxHeight (thus if the