1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 19:27:31 +08:00

Fix multiple disposals resulting in assert being hit

This commit is contained in:
Dean Herbert 2024-07-05 18:36:40 +09:00
parent 65418aca1a
commit 7efb4ce30a
No known key found for this signature in database
2 changed files with 12 additions and 3 deletions

View File

@ -101,6 +101,16 @@ namespace osu.Game.Tests.Visual.Menus
AddUntilStep("wait for restore to complete", () => Game.Audio.Tracks.AggregateVolume.Value, () => Is.EqualTo(normalVolume).Within(float.Epsilon));
}
[Test]
public void TestMultipleDisposalIsNoop()
{
IDisposable duckOp1 = null!;
AddStep("duck", () => duckOp1 = Game.MusicController.Duck());
AddStep("restore", () => duckOp1.Dispose());
AddStep("restore", () => duckOp1.Dispose());
}
[Test]
public void TestMultipleDucksDifferentPieces()
{

View File

@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio;
@ -284,8 +283,8 @@ namespace osu.Game.Overlays
void restoreDucking() => Schedule(() =>
{
Debug.Assert(duckOperations.Contains(parameters));
duckOperations.Remove(parameters);
if (!duckOperations.Remove(parameters))
return;
DuckParameters? restoreVolumeOperation = duckOperations.MinBy(p => p.DuckVolumeTo);
DuckParameters? restoreLowPassOperation = duckOperations.MinBy(p => p.DuckCutoffTo);