mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Fix RealmLive
not necessarily being in refreshed state due to potentially using update context
This commit is contained in:
@ -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>
|
||||
|
Reference in New Issue
Block a user