diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs
index 646ae3fae9..de65db1a5a 100644
--- a/osu.Game/Beatmaps/BeatmapManager.cs
+++ b/osu.Game/Beatmaps/BeatmapManager.cs
@@ -103,7 +103,7 @@ namespace osu.Game.Beatmaps
}
}
- private object ImportLock = new object();
+ private readonly object importLock = new object();
///
/// Import a beatmap from an .
@@ -112,7 +112,7 @@ namespace osu.Game.Beatmaps
public BeatmapSetInfo Import(ArchiveReader archiveReader)
{
// let's only allow one concurrent import at a time for now.
- lock (ImportLock)
+ lock (importLock)
{
BeatmapSetInfo set = importToStorage(archiveReader);
Import(set);
@@ -192,7 +192,8 @@ namespace osu.Game.Beatmaps
///
public void Reset()
{
- beatmaps.Reset();
+ lock (beatmaps)
+ beatmaps.Reset();
}
///
@@ -202,12 +203,15 @@ namespace osu.Game.Beatmaps
/// The first result for the provided query, or null if no results were found.
public BeatmapSetInfo QueryBeatmapSet(Func query)
{
- BeatmapSetInfo set = beatmaps.Query().FirstOrDefault(query);
+ lock (beatmaps)
+ {
+ BeatmapSetInfo set = beatmaps.Query().FirstOrDefault(query);
- if (set != null)
- beatmaps.Populate(set);
+ if (set != null)
+ beatmaps.Populate(set);
- return set;
+ return set;
+ }
}
///
@@ -215,7 +219,10 @@ namespace osu.Game.Beatmaps
///
/// The query.
/// Results from the provided query.
- public List QueryBeatmapSets(Expression> query) => beatmaps.QueryAndPopulate(query);
+ public List QueryBeatmapSets(Expression> query)
+ {
+ lock (beatmaps) return beatmaps.QueryAndPopulate(query);
+ }
///
/// Perform a lookup query on available s.
@@ -224,12 +231,15 @@ namespace osu.Game.Beatmaps
/// The first result for the provided query, or null if no results were found.
public BeatmapInfo QueryBeatmap(Func query)
{
- BeatmapInfo set = beatmaps.Query().FirstOrDefault(query);
+ lock (beatmaps)
+ {
+ BeatmapInfo set = beatmaps.Query().FirstOrDefault(query);
- if (set != null)
- beatmaps.Populate(set);
+ if (set != null)
+ beatmaps.Populate(set);
- return set;
+ return set;
+ }
}
///
@@ -237,7 +247,10 @@ namespace osu.Game.Beatmaps
///
/// The query.
/// Results from the provided query.
- public List QueryBeatmaps(Expression> query) => beatmaps.QueryAndPopulate(query);
+ public List QueryBeatmaps(Expression> query)
+ {
+ lock (beatmaps) return beatmaps.QueryAndPopulate(query);
+ }
///
/// Creates an from a valid storage path.
@@ -336,7 +349,7 @@ namespace osu.Game.Beatmaps
/// A list of available .
public List GetAllUsableBeatmapSets(bool populate = true)
{
- lock (this)
+ lock (beatmaps)
{
if (populate)
return beatmaps.QueryAndPopulate(b => !b.DeletePending).ToList();