mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 02:22:56 +08:00
Attempt to fix cross-thread database usage
This commit is contained in:
parent
da2f04c79c
commit
919e78a89a
@ -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>();
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user