1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 11:12:54 +08:00

Merge pull request #19984 from OliBomby/fix-merge-crash

Fixed merging circles at the same time causing a crash
This commit is contained in:
Bartłomiej Dach 2022-08-31 22:00:11 +02:00 committed by GitHub
commit a4dc3fe412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 3 deletions

View File

@ -190,7 +190,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
AddStep("add two circles on the same position", () =>
{
circle1 = new HitCircle();
circle2 = new HitCircle { Position = circle1.Position + Vector2.UnitX, StartTime = 1 };
circle2 = new HitCircle { Position = circle1.Position + Vector2.UnitX };
EditorClock.Seek(0);
EditorBeatmap.Add(circle1);
EditorBeatmap.Add(circle2);
@ -205,6 +205,33 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
&& EditorBeatmap.HitObjects.Contains(circle1) && EditorBeatmap.HitObjects.Contains(circle2));
}
[Test]
public void TestSameStartTimeMerge()
{
HitCircle? circle1 = null;
HitCircle? circle2 = null;
AddStep("add two circles at the same time", () =>
{
circle1 = new HitCircle();
circle2 = new HitCircle { Position = circle1.Position + 100 * Vector2.UnitX };
EditorClock.Seek(0);
EditorBeatmap.Add(circle1);
EditorBeatmap.Add(circle2);
EditorBeatmap.SelectedHitObjects.Add(circle1);
EditorBeatmap.SelectedHitObjects.Add(circle2);
});
moveMouseToHitObject(1);
AddAssert("merge option available", () => selectionHandler.ContextMenuItems.Any(o => o.Text.Value == "Merge selection"));
mergeSelection();
AddAssert("slider created", () => circle1 is not null && circle2 is not null && sliderCreatedFor(
(pos: circle1.Position, pathType: PathType.Linear),
(pos: circle2.Position, pathType: null)));
}
private void mergeSelection()
{
AddStep("merge selection", () =>

View File

@ -361,7 +361,7 @@ namespace osu.Game.Rulesets.Osu.Edit
if (!canMerge(mergeableObjects))
return;
ChangeHandler?.BeginChange();
EditorBeatmap.BeginChange();
// Have an initial slider object.
var firstHitObject = mergeableObjects[0];
@ -437,7 +437,7 @@ namespace osu.Game.Rulesets.Osu.Edit
SelectedItems.Clear();
SelectedItems.Add(mergedHitObject);
ChangeHandler?.EndChange();
EditorBeatmap.EndChange();
}
protected override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint<HitObject>> selection)