mirror of
https://github.com/ppy/osu
synced 2025-02-23 14:17:03 +00:00
Merge pull request #16278 from peppy/fix-skin-editor-overlay-show-thread-safetyu
Fix calling `SkinEditorOverlay.Show` before the overlay is loaded causing an exception
This commit is contained in:
commit
8f335c333c
@ -1,7 +1,6 @@
|
||||
// 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.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -67,18 +66,34 @@ namespace osu.Game.Skinning.Editor
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
// base call intentionally omitted.
|
||||
if (skinEditor == null)
|
||||
// base call intentionally omitted as we have custom behaviour.
|
||||
|
||||
if (skinEditor != null)
|
||||
{
|
||||
skinEditor = new SkinEditor(target);
|
||||
skinEditor.State.BindValueChanged(editorVisibilityChanged);
|
||||
|
||||
Debug.Assert(skinEditor != null);
|
||||
|
||||
LoadComponentAsync(skinEditor, AddInternal);
|
||||
}
|
||||
else
|
||||
skinEditor.Show();
|
||||
return;
|
||||
}
|
||||
|
||||
var editor = new SkinEditor(target);
|
||||
editor.State.BindValueChanged(editorVisibilityChanged);
|
||||
|
||||
skinEditor = editor;
|
||||
|
||||
// Schedule ensures that if `Show` is called before this overlay is loaded,
|
||||
// it will not throw (LoadComponentAsync requires the load target to be in a loaded state).
|
||||
Schedule(() =>
|
||||
{
|
||||
if (editor != skinEditor)
|
||||
return;
|
||||
|
||||
LoadComponentAsync(editor, _ =>
|
||||
{
|
||||
if (editor != skinEditor)
|
||||
return;
|
||||
|
||||
AddInternal(editor);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void editorVisibilityChanged(ValueChangedEvent<Visibility> visibility)
|
||||
|
Loading…
Reference in New Issue
Block a user