mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 15:47:26 +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
|
public IEnumerable<BeatmapSetInfo> BeatmapSets
|
||||||
{
|
{
|
||||||
get { return beatmapSets.Select(g => g.BeatmapSet); }
|
get => beatmapSets.Select(g => g.BeatmapSet);
|
||||||
set
|
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);
|
BeatmapSetsChanged?.Invoke();
|
||||||
newRoot.Filter(activeCriteria);
|
initialLoadComplete = true;
|
||||||
|
});
|
||||||
// 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;
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly List<float> yPositions = new List<float>();
|
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");
|
sampleChangeDifficulty = await audio.Sample.GetAsync(@"SongSelect/select-difficulty");
|
||||||
sampleChangeBeatmap = await audio.Sample.GetAsync(@"SongSelect/select-expand");
|
sampleChangeBeatmap = await audio.Sample.GetAsync(@"SongSelect/select-expand");
|
||||||
|
|
||||||
Carousel.BeatmapSets = this.beatmaps.GetAllUsableBeatmapSetsEnumerable();
|
Carousel.LoadBeatmapSetsFromManager(this.beatmaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Edit(BeatmapInfo beatmap)
|
public void Edit(BeatmapInfo beatmap)
|
||||||
|
Loading…
Reference in New Issue
Block a user