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:
parent
65418aca1a
commit
7efb4ce30a
@ -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()
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user