fix with new event

This commit is contained in:
OliBomby 2022-09-13 02:20:52 +02:00
parent a1f4724685
commit fd48249eef
2 changed files with 10 additions and 4 deletions

View File

@ -24,11 +24,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
{ {
base.LoadComplete(); base.LoadComplete();
editorBeatmap.HitObjectUpdated += hitObjectUpdated; editorBeatmap.SelectionBlueprintsShouldBeSorted += SortInternal;
} }
private void hitObjectUpdated(HitObject _) => SortInternal();
public override void Add(SelectionBlueprint<HitObject> drawable) public override void Add(SelectionBlueprint<HitObject> drawable)
{ {
SortInternal(); SortInternal();
@ -72,7 +70,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
base.Dispose(isDisposing); base.Dispose(isDisposing);
if (editorBeatmap != null) if (editorBeatmap != null)
editorBeatmap.HitObjectUpdated -= hitObjectUpdated; editorBeatmap.SelectionBlueprintsShouldBeSorted -= SortInternal;
} }
} }
} }

View File

@ -48,6 +48,11 @@ namespace osu.Game.Screens.Edit
/// </summary> /// </summary>
public event Action<HitObject> HitObjectUpdated; public event Action<HitObject> HitObjectUpdated;
/// <summary>
/// Invoked after <see cref="HitObjects"/> is updated during <see cref="UpdateState"/> and blueprints need to be sorted immediately to prevent a crash.
/// </summary>
public event Action SelectionBlueprintsShouldBeSorted;
/// <summary> /// <summary>
/// All currently selected <see cref="HitObject"/>s. /// All currently selected <see cref="HitObject"/>s.
/// </summary> /// </summary>
@ -331,6 +336,9 @@ namespace osu.Game.Screens.Edit
beatmapProcessor?.PostProcess(); beatmapProcessor?.PostProcess();
// Signal selection blueprint sorting because it is possible that the beatmap processor changed the order of the selection blueprints
SelectionBlueprintsShouldBeSorted?.Invoke();
// callbacks may modify the lists so let's be safe about it // callbacks may modify the lists so let's be safe about it
var deletes = batchPendingDeletes.ToArray(); var deletes = batchPendingDeletes.ToArray();
batchPendingDeletes.Clear(); batchPendingDeletes.Clear();