1
0
mirror of https://github.com/ppy/osu synced 2025-03-05 02:49:30 +00:00

Merge pull request from OliBomby/fix-reverse-crash

Prevent infinite repeat count when adjusting repeats of 0 length slider
This commit is contained in:
Dean Herbert 2023-05-02 19:53:26 +09:00 committed by GitHub
commit 94ae9d7664
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 1 deletions
osu.Game.Tests/Visual/Editing
osu.Game/Screens/Edit/Compose/Components/Timeline

View File

@ -77,5 +77,39 @@ namespace osu.Game.Tests.Visual.Editing
AddAssert("object has non-zero duration", () => EditorBeatmap.HitObjects.OfType<IHasDuration>().Single().Duration > 0);
}
[Test]
public void TestDisallowRepeatsOnZeroDurationObjects()
{
DragArea dragArea;
AddStep("add zero length slider", () =>
{
EditorBeatmap.Clear();
EditorBeatmap.Add(new Slider
{
Position = new Vector2(256, 256),
StartTime = 2700
});
});
AddStep("hold down drag bar", () =>
{
// distinguishes between the actual drag bar and its "underlay shadow".
dragArea = this.ChildrenOfType<DragArea>().Single(bar => bar.HandlePositionalInput);
InputManager.MoveMouseTo(dragArea);
InputManager.PressButton(MouseButton.Left);
});
AddStep("try to extend drag bar", () =>
{
var blueprint = this.ChildrenOfType<TimelineHitObjectBlueprint>().Single();
InputManager.MoveMouseTo(blueprint.SelectionQuad.TopLeft + new Vector2(100, 0));
});
AddStep("release button", () => InputManager.PressButton(MouseButton.Left));
AddAssert("object has zero repeats", () => EditorBeatmap.HitObjects.OfType<IHasRepeats>().Single().RepeatCount == 0);
}
}
}

View File

@ -414,7 +414,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
double lengthOfOneRepeat = repeatHitObject.Duration / (repeatHitObject.RepeatCount + 1);
int proposedCount = Math.Max(0, (int)Math.Round(proposedDuration / lengthOfOneRepeat) - 1);
if (proposedCount == repeatHitObject.RepeatCount)
if (proposedCount == repeatHitObject.RepeatCount || lengthOfOneRepeat == 0)
return;
repeatHitObject.RepeatCount = proposedCount;