1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:37:28 +08:00

Merge pull request #25547 from bdach/skin-editor-paste-catching-fire

Fix skin editor crashing when pasting with nothing in clipboard
This commit is contained in:
Dean Herbert 2023-11-23 16:15:11 +09:00 committed by GitHub
commit 5d367c247c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 0 deletions

View File

@ -335,6 +335,40 @@ namespace osu.Game.Tests.Visual.Gameplay
AddAssert("value is less than default", () => hitErrorMeter.JudgementLineThickness.Value < hitErrorMeter.JudgementLineThickness.Default);
}
[Test]
public void TestCopyPaste()
{
AddStep("paste", () =>
{
InputManager.PressKey(Key.LControl);
InputManager.Key(Key.V);
InputManager.ReleaseKey(Key.LControl);
});
// no assertions. just make sure nothing crashes.
AddStep("select bar hit error blueprint", () =>
{
var blueprint = skinEditor.ChildrenOfType<SkinBlueprint>().First(b => b.Item is BarHitErrorMeter);
skinEditor.SelectedComponents.Clear();
skinEditor.SelectedComponents.Add(blueprint.Item);
});
AddStep("copy", () =>
{
InputManager.PressKey(Key.LControl);
InputManager.Key(Key.C);
InputManager.ReleaseKey(Key.LControl);
});
AddStep("paste", () =>
{
InputManager.PressKey(Key.LControl);
InputManager.Key(Key.V);
InputManager.ReleaseKey(Key.LControl);
});
AddAssert("three hit error meters present",
() => skinEditor.ChildrenOfType<SkinBlueprint>().Count(b => b.Item is BarHitErrorMeter),
() => Is.EqualTo(3));
}
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
private partial class TestSkinEditorChangeHandler : SkinEditorChangeHandler

View File

@ -510,6 +510,9 @@ namespace osu.Game.Overlays.SkinEditor
protected void Paste()
{
if (!canPaste.Value)
return;
changeHandler?.BeginChange();
var drawableInfo = JsonConvert.DeserializeObject<SerialisedDrawableInfo[]>(clipboard.Content.Value);