Skip to content

Commit

Permalink
Merge pull request #25016 from peppy/fix-waveform-comparison-crash
Browse files Browse the repository at this point in the history
Fix `WaveformComparisonDisplay` potentially crashing on invalid track length
  • Loading branch information
bdach authored Oct 5, 2023
2 parents 9649cc8 + 61fd418 commit 4d315cb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions osu.Game/Screens/Edit/Timing/WaveformComparisonDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected override void LoadComplete()
controlPointGroups.BindTo(editorBeatmap.ControlPointInfo.Groups);
controlPointGroups.BindCollectionChanged((_, _) => updateTimingGroup());

beatLength.BindValueChanged(_ => regenerateDisplay(true), true);
beatLength.BindValueChanged(_ => Scheduler.AddOnce(regenerateDisplay, true), true);

displayLocked.BindValueChanged(locked =>
{
Expand Down Expand Up @@ -186,11 +186,18 @@ private void showFromTime(double time, bool animated)
return;

displayedTime = time;
regenerateDisplay(animated);
Scheduler.AddOnce(regenerateDisplay, animated);
}

private void regenerateDisplay(bool animated)
{
// Before a track is loaded, it won't have a valid length, which will break things.
if (!beatmap.Value.Track.IsLoaded)
{
Scheduler.AddOnce(regenerateDisplay, animated);
return;
}

double index = (displayedTime - selectedGroupStartTime) / timingPoint.BeatLength;

// Chosen as a pretty usable number across all BPMs.
Expand Down

0 comments on commit 4d315cb

Please sign in to comment.