1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 01:27:29 +08:00

Attempt to fix cross-thread database usage

This commit is contained in:
Dean Herbert 2018-08-29 01:42:25 +09:00
parent da2f04c79c
commit 919e78a89a
2 changed files with 28 additions and 24 deletions

View File

@ -64,32 +64,36 @@ namespace osu.Game.Screens.Select
public IEnumerable<BeatmapSetInfo> BeatmapSets
{
get { return beatmapSets.Select(g => g.BeatmapSet); }
set
get => beatmapSets.Select(g => g.BeatmapSet);
set => loadBeatmapSets(() => value);
}
public void LoadBeatmapSetsFromManager(BeatmapManager manager) => loadBeatmapSets(manager.GetAllUsableBeatmapSetsEnumerable);
private void loadBeatmapSets(Func<IEnumerable<BeatmapSetInfo>> beatmapSets)
{
CarouselRoot newRoot = new CarouselRoot(this);
Task.Run(() =>
{
CarouselRoot newRoot = new CarouselRoot(this);
beatmapSets().Select(createCarouselSet).Where(g => g != null).ForEach(newRoot.AddChild);
newRoot.Filter(activeCriteria);
Task.Run(() =>
// preload drawables as the ctor overhead is quite high currently.
var _ = newRoot.Drawables;
}).ContinueWith(_ => Schedule(() =>
{
root = newRoot;
scrollableContent.Clear(false);
itemsCache.Invalidate();
scrollPositionCache.Invalidate();
Schedule(() =>
{
value.Select(createCarouselSet).Where(g => g != null).ForEach(newRoot.AddChild);
newRoot.Filter(activeCriteria);
// preload drawables as the ctor overhead is quite high currently.
var _ = newRoot.Drawables;
}).ContinueWith(_ => Schedule(() =>
{
root = newRoot;
scrollableContent.Clear(false);
itemsCache.Invalidate();
scrollPositionCache.Invalidate();
Schedule(() =>
{
BeatmapSetsChanged?.Invoke();
initialLoadComplete = true;
});
}));
}
BeatmapSetsChanged?.Invoke();
initialLoadComplete = true;
});
}));
}
private readonly List<float> yPositions = new List<float>();

View File

@ -222,7 +222,7 @@ namespace osu.Game.Screens.Select
sampleChangeDifficulty = await audio.Sample.GetAsync(@"SongSelect/select-difficulty");
sampleChangeBeatmap = await audio.Sample.GetAsync(@"SongSelect/select-expand");
Carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSetsEnumerable();
Carousel.LoadBeatmapSetsFromManager(this.beatmaps);
}
public void Edit(BeatmapInfo beatmap)