1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:12:54 +08:00

Merge pull request #14890 from peppy/skin-editor-nullable-allowed

Fix skin editor potentially crashing during close process
This commit is contained in:
Dan Balasescu 2021-09-29 20:19:19 +09:00 committed by GitHub
commit 8bbd8cd948
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View File

@ -22,7 +22,6 @@ using Humanizer;
using JetBrains.Annotations;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Development;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input;

View File

@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Diagnostics;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -20,6 +22,8 @@ namespace osu.Game.Skinning.Editor
public class SkinEditorOverlay : CompositeDrawable, IKeyBindingHandler<GlobalAction>
{
private readonly ScalingContainer target;
[CanBeNull]
private SkinEditor skinEditor;
public const float VISIBLE_TARGET_SCALE = 0.8f;
@ -63,7 +67,7 @@ namespace osu.Game.Skinning.Editor
public override void Hide()
{
// base call intentionally omitted.
skinEditor.Hide();
skinEditor?.Hide();
}
public override void Show()
@ -71,8 +75,12 @@ namespace osu.Game.Skinning.Editor
// base call intentionally omitted.
if (skinEditor == null)
{
LoadComponentAsync(skinEditor = new SkinEditor(target), AddInternal);
skinEditor = new SkinEditor(target);
skinEditor.State.BindValueChanged(editorVisibilityChanged);
Debug.Assert(skinEditor != null);
LoadComponentAsync(skinEditor, AddInternal);
}
else
skinEditor.Show();
@ -98,8 +106,13 @@ namespace osu.Game.Skinning.Editor
}
}
private void updateMasking() =>
private void updateMasking()
{
if (skinEditor == null)
return;
target.Masking = skinEditor.State.Value == Visibility.Visible;
}
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{