From 4dd225fdc8184f062292ff15c258076f29e0bfa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 19 Jul 2024 08:26:53 +0200 Subject: [PATCH] Fix compose blueprint container not unsubscribing from event Closes https://github.com/ppy/osu/issues/28938. This is related to reloading the composer on timing point changes in scrolling rulesets. The lack of unsubscription from this would cause blueprints to be created for disposed composers via the `hitObjectAdded()` flow. The following line looks as if a sync load should be forced on a newly created placement blueprint: https://github.com/ppy/osu/blob/da4d37c4aded5e10d0a65ff44a08a886e3897e19/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs#L364 however, it is not the case if the parent (`placementBlueprintContainer`) is disposed, which it would be in this case. Therefore, the blueprint stays `NotLoaded` rather than `Ready`, therefore it never receives its DI dependencies, therefore it dies on an `EditorBeatmap` nullref. --- .../Edit/Compose/Components/ComposeBlueprintContainer.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs index fc8bce4c96..f1294ccc3c 100644 --- a/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/ComposeBlueprintContainer.cs @@ -9,6 +9,7 @@ using Humanizer; using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Extensions.ObjectExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; @@ -405,5 +406,13 @@ namespace osu.Game.Screens.Edit.Compose.Components CommitIfPlacementActive(); } } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + if (Beatmap.IsNotNull()) + Beatmap.HitObjectAdded -= hitObjectAdded; + } } }