diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index a2b44aab52..e0a22460ef 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -135,7 +135,7 @@ public IBeatmap GetPlayableBeatmap(RulesetInfo ruleset) public bool BackgroundLoaded => background.IsResultAvailable; public Texture Background => background.Value; - protected virtual bool BackgroundStillValid(Texture b) => b == null || !b.IsDisposed; + protected virtual bool BackgroundStillValid(Texture b) => b == null || b.Available; protected abstract Texture GetBackground(); private readonly RecyclableLazy background; diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index e9fe943f15..f4f169f27c 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -59,7 +59,7 @@ public abstract class ArchiveModelManager : ICanAcceptFiles // ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised) private ArchiveImportIPCChannel ipc; - private readonly List cachedEvents = new List(); + private readonly List queuedEvents = new List(); /// /// Allows delaying of outwards events until an operation is confirmed (at a database level). @@ -77,20 +77,26 @@ public abstract class ArchiveModelManager : ICanAcceptFiles /// Whether the flushed events should be performed. private void flushEvents(bool perform) { + Action[] events; + lock (queuedEvents) + { + events = queuedEvents.ToArray(); + queuedEvents.Clear(); + } + if (perform) { - foreach (var a in cachedEvents) + foreach (var a in events) a.Invoke(); } - cachedEvents.Clear(); delayingEvents = false; } private void handleEvent(Action a) { if (delayingEvents) - cachedEvents.Add(a); + lock (queuedEvents) queuedEvents.Add(a); else a.Invoke(); } diff --git a/osu.Game/Tests/Visual/TestCasePlayer.cs b/osu.Game/Tests/Visual/TestCasePlayer.cs index 9afb1dd6cd..9e499cb961 100644 --- a/osu.Game/Tests/Visual/TestCasePlayer.cs +++ b/osu.Game/Tests/Visual/TestCasePlayer.cs @@ -54,7 +54,7 @@ private void load(RulesetStore rulesets) AddStep(r.Name, () => p = loadPlayerFor(r)); AddUntilStep(() => ContinueCondition(p)); - AddAssert("no leaked beatmaps", () => + AddUntilStep(() => { p = null; @@ -64,9 +64,9 @@ private void load(RulesetStore rulesets) workingWeakReferences.ForEachAlive(_ => count++); return count == 1; - }); + }, "no leaked beatmaps"); - AddAssert("no leaked players", () => + AddUntilStep(() => { GC.Collect(); GC.WaitForPendingFinalizers(); @@ -74,7 +74,7 @@ private void load(RulesetStore rulesets) playerWeakReferences.ForEachAlive(_ => count++); return count == 1; - }); + }, "no leaked players"); } } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 3e16e90d06..83ab5534c6 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -18,7 +18,7 @@ - +