From b0c8a92ea4995a7f87c819de70b8f85f2aa174de Mon Sep 17 00:00:00 2001 From: Ezekiel Bethel Date: Sat, 10 Feb 2018 18:18:52 +0000 Subject: [PATCH] Make HSessionObj implement IDisposable, so that objects that have handles created to them are disposed when the handles are closed. --- Ryujinx/OsHle/Handles/HSessionObj.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Ryujinx/OsHle/Handles/HSessionObj.cs b/Ryujinx/OsHle/Handles/HSessionObj.cs index c1e5e41a4c..d2b2b0d78a 100644 --- a/Ryujinx/OsHle/Handles/HSessionObj.cs +++ b/Ryujinx/OsHle/Handles/HSessionObj.cs @@ -1,6 +1,8 @@ +using System; + namespace Ryujinx.OsHle.Handles { - class HSessionObj : HSession + class HSessionObj : HSession, IDisposable { public object Obj { get; private set; } @@ -8,5 +10,21 @@ namespace Ryujinx.OsHle.Handles { this.Obj = Obj; } + + public void Dispose() + { + Dispose(true); + } + + protected virtual void Dispose(bool Disposing) + { + if(Disposing && Obj != null) + { + if(Obj is IDisposable DisposableObj) + { + DisposableObj.Dispose(); + } + } + } } } \ No newline at end of file