1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 07:22:55 +08:00

Merge pull request #15855 from peppy/live-post-construction-attach

Fix `RealmLive` not working if data is attached to realm post-`ToLive` call
This commit is contained in:
Dan Balasescu 2021-11-29 18:14:08 +09:00 committed by GitHub
commit e2cb420c06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View File

@ -29,6 +29,22 @@ namespace osu.Game.Tests.Database
});
}
[Test]
public void TestAccessAfterAttach()
{
RunTestWithRealm((realmFactory, _) =>
{
var beatmap = new RealmBeatmap(CreateRuleset(), new RealmBeatmapDifficulty(), new RealmBeatmapMetadata());
var liveBeatmap = beatmap.ToLive();
using (var context = realmFactory.CreateContext())
context.Write(r => r.Add(beatmap));
Assert.IsFalse(liveBeatmap.PerformRead(l => l.Hidden));
});
}
[Test]
public void TestAccessNonManaged()
{

View File

@ -17,7 +17,7 @@ namespace osu.Game.Database
{
public Guid ID { get; }
public bool IsManaged { get; }
public bool IsManaged => data.IsManaged;
private readonly SynchronizationContext? fetchedContext;
private readonly int fetchedThreadId;
@ -37,8 +37,6 @@ namespace osu.Game.Database
if (data.IsManaged)
{
IsManaged = true;
fetchedContext = SynchronizationContext.Current;
fetchedThreadId = Thread.CurrentThread.ManagedThreadId;
}