mirror of
https://github.com/ppy/osu
synced 2024-12-14 10:57:41 +00:00
Avoid hard crash if Save()
is called before preparing for mutation
This commit is contained in:
parent
9df08560b6
commit
be187e8ebd
@ -38,6 +38,8 @@ namespace osu.Game.Skinning.Editor
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
private bool hasBegunMutating;
|
||||
|
||||
public SkinEditor(Drawable targetScreen)
|
||||
{
|
||||
this.targetScreen = targetScreen;
|
||||
@ -139,7 +141,11 @@ namespace osu.Game.Skinning.Editor
|
||||
// schedule ensures this only happens when the skin editor is visible.
|
||||
// also avoid some weird endless recursion / bindable feedback loop (something to do with tracking skins across three different bindable types).
|
||||
// probably something which will be factored out in a future database refactor so not too concerning for now.
|
||||
currentSkin.BindValueChanged(skin => Scheduler.AddOnce(skinChanged), true);
|
||||
currentSkin.BindValueChanged(skin =>
|
||||
{
|
||||
hasBegunMutating = false;
|
||||
Scheduler.AddOnce(skinChanged);
|
||||
}, true);
|
||||
}
|
||||
|
||||
private void skinChanged()
|
||||
@ -161,6 +167,7 @@ namespace osu.Game.Skinning.Editor
|
||||
});
|
||||
|
||||
skins.EnsureMutableSkin();
|
||||
hasBegunMutating = true;
|
||||
}
|
||||
|
||||
private void placeComponent(Type type)
|
||||
@ -194,6 +201,9 @@ namespace osu.Game.Skinning.Editor
|
||||
|
||||
public void Save()
|
||||
{
|
||||
if (!hasBegunMutating)
|
||||
return;
|
||||
|
||||
SkinnableElementTargetContainer[] targetContainers = targetScreen.ChildrenOfType<SkinnableElementTargetContainer>().ToArray();
|
||||
|
||||
foreach (var t in targetContainers)
|
||||
|
Loading…
Reference in New Issue
Block a user