mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 22:33:05 +08:00
fix same time merge causing crash
This commit is contained in:
parent
16e0ec2f88
commit
ff2eac79d1
@ -190,7 +190,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
|||||||
AddStep("add two circles on the same position", () =>
|
AddStep("add two circles on the same position", () =>
|
||||||
{
|
{
|
||||||
circle1 = new HitCircle();
|
circle1 = new HitCircle();
|
||||||
circle2 = new HitCircle { Position = circle1.Position + Vector2.UnitX, StartTime = 1 };
|
circle2 = new HitCircle { Position = circle1.Position + Vector2.UnitX };
|
||||||
EditorClock.Seek(0);
|
EditorClock.Seek(0);
|
||||||
EditorBeatmap.Add(circle1);
|
EditorBeatmap.Add(circle1);
|
||||||
EditorBeatmap.Add(circle2);
|
EditorBeatmap.Add(circle2);
|
||||||
@ -205,6 +205,33 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
|||||||
&& EditorBeatmap.HitObjects.Contains(circle1) && EditorBeatmap.HitObjects.Contains(circle2));
|
&& 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()
|
private void mergeSelection()
|
||||||
{
|
{
|
||||||
AddStep("merge selection", () =>
|
AddStep("merge selection", () =>
|
||||||
|
@ -363,6 +363,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ChangeHandler?.BeginChange();
|
ChangeHandler?.BeginChange();
|
||||||
|
EditorBeatmap.BeginChange();
|
||||||
|
|
||||||
// Have an initial slider object.
|
// Have an initial slider object.
|
||||||
var firstHitObject = mergeableObjects[0];
|
var firstHitObject = mergeableObjects[0];
|
||||||
@ -438,6 +439,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
SelectedItems.Clear();
|
SelectedItems.Clear();
|
||||||
SelectedItems.Add(mergedHitObject);
|
SelectedItems.Add(mergedHitObject);
|
||||||
|
|
||||||
|
EditorBeatmap.EndChange();
|
||||||
ChangeHandler?.EndChange();
|
ChangeHandler?.EndChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user