From 76cc2f9f22380d132500d6b5450ae1a76e868e49 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 5 Oct 2023 14:58:50 +0900 Subject: [PATCH 1/2] Fix `WaveformComparisonDisplay` potentially crashing on invalid track length As seen at https://github.com/ppy/osu/runs/17415814918#r0s2. --- osu.Game/Screens/Edit/Timing/WaveformComparisonDisplay.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Screens/Edit/Timing/WaveformComparisonDisplay.cs b/osu.Game/Screens/Edit/Timing/WaveformComparisonDisplay.cs index 3b3acea935..d598b2cfbf 100644 --- a/osu.Game/Screens/Edit/Timing/WaveformComparisonDisplay.cs +++ b/osu.Game/Screens/Edit/Timing/WaveformComparisonDisplay.cs @@ -191,6 +191,10 @@ namespace osu.Game.Screens.Edit.Timing 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) + return; + double index = (displayedTime - selectedGroupStartTime) / timingPoint.BeatLength; // Chosen as a pretty usable number across all BPMs. From 61fd4186af8781af2791e6760d925760beba8f21 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 5 Oct 2023 22:55:23 +0900 Subject: [PATCH 2/2] Ensure `regenerateDisplay` is eventually performed if originally called before load --- osu.Game/Screens/Edit/Timing/WaveformComparisonDisplay.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Edit/Timing/WaveformComparisonDisplay.cs b/osu.Game/Screens/Edit/Timing/WaveformComparisonDisplay.cs index d598b2cfbf..856bc7c303 100644 --- a/osu.Game/Screens/Edit/Timing/WaveformComparisonDisplay.cs +++ b/osu.Game/Screens/Edit/Timing/WaveformComparisonDisplay.cs @@ -94,7 +94,7 @@ namespace osu.Game.Screens.Edit.Timing controlPointGroups.BindTo(editorBeatmap.ControlPointInfo.Groups); controlPointGroups.BindCollectionChanged((_, _) => updateTimingGroup()); - beatLength.BindValueChanged(_ => regenerateDisplay(true), true); + beatLength.BindValueChanged(_ => Scheduler.AddOnce(regenerateDisplay, true), true); displayLocked.BindValueChanged(locked => { @@ -186,14 +186,17 @@ namespace osu.Game.Screens.Edit.Timing 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;