1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 12:17:46 +08:00

Don't dispose fetched realm instance when using RealmLive.Value

See https://github.com/realm/realm-dotnet/discussions/2734#discussioncomment-1705038 for reasoning.
This commit is contained in:
Dean Herbert 2021-11-26 21:33:11 +09:00
parent e40e5096ea
commit cb8fa80352

View File

@ -102,10 +102,11 @@ namespace osu.Game.Database
if (originalDataValid) if (originalDataValid)
return data; return data;
T retrieved; if (!isCorrectThread)
throw new InvalidOperationException($"Can't use {nameof(Value)} unless on the same thread the original data was fetched from.");
using (var realm = Realm.GetInstance(data.Realm.Config)) var realm = Realm.GetInstance(data.Realm.Config);
retrieved = realm.Find<T>(ID); var retrieved = realm.Find<T>(ID);
if (!retrieved.IsValid) if (!retrieved.IsValid)
throw new InvalidOperationException("Attempted to access value without an open context"); throw new InvalidOperationException("Attempted to access value without an open context");