1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 13:37:25 +08:00

Ensure the main realm context is closed when the factory is disposed

This commit is contained in:
Dean Herbert 2021-01-15 14:26:06 +09:00
parent 693602513e
commit 3e366b1f15
2 changed files with 12 additions and 0 deletions

View File

@ -83,6 +83,7 @@ namespace osu.Game.Tests.Database
[TearDown]
public void TearDown()
{
realmContextFactory.Dispose();
storage.DeleteDirectory(string.Empty);
}

View File

@ -36,6 +36,9 @@ namespace osu.Game.Database
{
get
{
if (IsDisposed)
throw new InvalidOperationException($"Attempted to access {nameof(Context)} on a disposed context factory");
if (context == null)
{
context = createContext();
@ -92,6 +95,14 @@ namespace osu.Game.Database
{
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
context?.Dispose();
context = null;
}
/// <summary>
/// A transaction used for making changes to realm data.
/// </summary>