1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 16:32:54 +08:00

Fix RealmLive not necessarily being in refreshed state due to potentially using update context

This commit is contained in:
Dean Herbert 2022-01-21 17:27:30 +09:00
parent 114c9e8c1f
commit d2655c0825

View File

@ -51,7 +51,21 @@ namespace osu.Game.Database
return;
}
realmFactory.Run(realm => perform(realm.Find<T>(ID)));
realmFactory.Run(realm =>
{
var found = realm.Find<T>(ID);
if (found == null)
{
// It may be that we access this from the update thread before a refresh has taken place.
// To ensure that behaviour matches what we'd expect (the object *is* available), force
// a refresh to bring in any off-thread changes immediately.
realm.Refresh();
found = realm.Find<T>(ID);
}
perform(found);
});
}
/// <summary>