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:
parent
693602513e
commit
3e366b1f15
@ -83,6 +83,7 @@ namespace osu.Game.Tests.Database
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
realmContextFactory.Dispose();
|
||||
storage.DeleteDirectory(string.Empty);
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user