mirror of
https://github.com/osukey/osukey.git
synced 2025-06-25 05:07:59 +09: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]
|
[TearDown]
|
||||||
public void TearDown()
|
public void TearDown()
|
||||||
{
|
{
|
||||||
|
realmContextFactory.Dispose();
|
||||||
storage.DeleteDirectory(string.Empty);
|
storage.DeleteDirectory(string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,9 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
if (IsDisposed)
|
||||||
|
throw new InvalidOperationException($"Attempted to access {nameof(Context)} on a disposed context factory");
|
||||||
|
|
||||||
if (context == null)
|
if (context == null)
|
||||||
{
|
{
|
||||||
context = createContext();
|
context = createContext();
|
||||||
@ -92,6 +95,14 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
|
context?.Dispose();
|
||||||
|
context = null;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A transaction used for making changes to realm data.
|
/// A transaction used for making changes to realm data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user