mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 08:43:01 +08:00
Schedule callback instead
This commit is contained in:
parent
e7981eae9b
commit
8a2026e305
@ -55,6 +55,8 @@ namespace osu.Game.Collections
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Collections.CollectionChanged += collectionsChanged;
|
||||
|
||||
if (storage.Exists(database_backup_name))
|
||||
{
|
||||
// If a backup file exists, it means the previous write operation didn't run to completion.
|
||||
@ -66,10 +68,6 @@ namespace osu.Game.Collections
|
||||
File.Copy(storage.GetFullPath(database_backup_name), storage.GetFullPath(database_name));
|
||||
}
|
||||
|
||||
// Only accept changes after/if the above succeeds to prevent simultaneously accessing either file.
|
||||
// Todo: This really should not be delayed like this, but is unlikely to cause issues because CollectionManager loads very early in execution.
|
||||
Collections.CollectionChanged += collectionsChanged;
|
||||
|
||||
if (storage.Exists(database_name))
|
||||
{
|
||||
List<BeatmapCollection> beatmapCollections;
|
||||
@ -82,7 +80,7 @@ namespace osu.Game.Collections
|
||||
}
|
||||
}
|
||||
|
||||
private void collectionsChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
private void collectionsChanged(object sender, NotifyCollectionChangedEventArgs e) => Schedule(() =>
|
||||
{
|
||||
switch (e.Action)
|
||||
{
|
||||
@ -106,7 +104,7 @@ namespace osu.Game.Collections
|
||||
}
|
||||
|
||||
backgroundSave();
|
||||
}
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// Set an endpoint for notifications to be posted to.
|
||||
|
Loading…
Reference in New Issue
Block a user