From 28d6ff5d9c8bac9390e7576829623798934fc61a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 Dec 2021 12:36:01 +0900 Subject: [PATCH 1/3] Fix potential wrong thread mutation in `ColourHitErrorMeter` --- .../Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index 5012be7249..00e6059541 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -53,13 +53,13 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters LayoutEasing = Easing.OutQuint; } - public void Push(Color4 colour) + public void Push(Color4 colour) => Schedule(() => { Add(new HitErrorCircle(colour, drawable_judgement_size)); if (Children.Count > max_available_judgements) Children.FirstOrDefault(c => !c.IsRemoved)?.Remove(); - } + }); } internal class HitErrorCircle : Container From 52db7b36fc44a66d64a5b68d5a266ece48a2cebc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 Dec 2021 12:55:21 +0900 Subject: [PATCH 2/3] Move `Schedule` call to base implementation of error meter for extra safety --- .../Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs | 4 ++-- osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs index 00e6059541..5012be7249 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/ColourHitErrorMeter.cs @@ -53,13 +53,13 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters LayoutEasing = Easing.OutQuint; } - public void Push(Color4 colour) => Schedule(() => + public void Push(Color4 colour) { Add(new HitErrorCircle(colour, drawable_judgement_size)); if (Children.Count > max_available_judgements) Children.FirstOrDefault(c => !c.IsRemoved)?.Remove(); - }); + } } internal class HitErrorCircle : Container diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs index c7b06a3a2c..16c23f07f5 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs @@ -40,9 +40,14 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters if (gameplayClockContainer != null) gameplayClockContainer.OnSeek += Clear; - processor.NewJudgement += OnNewJudgement; + // Scheduled as meter implementations are likely going to change/add drawables when reacting to this. + processor.NewJudgement += j => Schedule(() => OnNewJudgement(j)); } + /// + /// Fired when a new judgement arrives. + /// + /// The new judgement. protected abstract void OnNewJudgement(JudgementResult judgement); protected Color4 GetColourForHitResult(HitResult result) From edcbd4de6d27cd9788523064207e4111d2d99f80 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 Dec 2021 13:05:26 +0900 Subject: [PATCH 3/3] Fix incorrect event unbind logic --- osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs b/osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs index 16c23f07f5..1f08cb8aa7 100644 --- a/osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs +++ b/osu.Game/Screens/Play/HUD/HitErrorMeters/HitErrorMeter.cs @@ -40,10 +40,12 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters if (gameplayClockContainer != null) gameplayClockContainer.OnSeek += Clear; - // Scheduled as meter implementations are likely going to change/add drawables when reacting to this. - processor.NewJudgement += j => Schedule(() => OnNewJudgement(j)); + processor.NewJudgement += processorNewJudgement; } + // Scheduled as meter implementations are likely going to change/add drawables when reacting to this. + private void processorNewJudgement(JudgementResult j) => Schedule(() => OnNewJudgement(j)); + /// /// Fired when a new judgement arrives. /// @@ -89,7 +91,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters base.Dispose(isDisposing); if (processor != null) - processor.NewJudgement -= OnNewJudgement; + processor.NewJudgement -= processorNewJudgement; if (gameplayClockContainer != null) gameplayClockContainer.OnSeek -= Clear;