mirror of
https://github.com/ppy/osu
synced 2025-03-05 02:49:30 +00:00
Merge pull request #23357 from OliBomby/fix-reverse-crash
Prevent infinite repeat count when adjusting repeats of 0 length slider
This commit is contained in:
commit
94ae9d7664
osu.Game.Tests/Visual/Editing
osu.Game/Screens/Edit/Compose/Components/Timeline
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user