Fix being able to paste objects while composer is loading

Would lead to exceptions due to modification of `Beatmap.HitObjects`
during its enumeration by `DrawableRuleset`, which was happening as an
async load via `EditorScreenWithTimeline.CreateMainContent()`.
This commit is contained in:
Bartłomiej Dach 2021-12-07 21:00:25 +01:00
parent 74db8da11b
commit 10dd64e07c
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497

View File

@ -83,7 +83,9 @@ namespace osu.Game.Screens.Edit.Compose
{
base.LoadComplete();
EditorBeatmap.SelectedHitObjects.BindCollectionChanged((_, __) => updateClipboardActionAvailability());
clipboard.BindValueChanged(_ => updateClipboardActionAvailability(), true);
clipboard.BindValueChanged(_ => updateClipboardActionAvailability());
composer.OnLoadComplete += _ => updateClipboardActionAvailability();
updateClipboardActionAvailability();
}
#region Clipboard operations
@ -131,7 +133,7 @@ namespace osu.Game.Screens.Edit.Compose
private void updateClipboardActionAvailability()
{
CanCut.Value = CanCopy.Value = EditorBeatmap.SelectedHitObjects.Any();
CanPaste.Value = !string.IsNullOrEmpty(clipboard.Value);
CanPaste.Value = composer.IsLoaded && !string.IsNullOrEmpty(clipboard.Value);
}
private string formatSelectionAsString()