0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2024-12-22 23:55:47 +00:00

Make HSessionObj implement IDisposable (#10)

* Make HSessionObj implement IDisposable, so that objects that have handles created to them are disposed when the handles are closed.

* Spelling fix: GenertateObjectId -> GenerateObjectId
This commit is contained in:
Stary 2001 2018-02-10 18:31:40 +00:00 committed by gdkchan
parent 55743c0cba
commit 2f2b60db4c
4 changed files with 22 additions and 4 deletions

View file

@ -17,7 +17,7 @@ namespace Ryujinx.OsHle.Handles
ObjIds = new IdPool(); ObjIds = new IdPool();
} }
public int GenertateObjectId(object Obj) public int GenerateObjectId(object Obj)
{ {
int Id = ObjIds.GenerateId(); int Id = ObjIds.GenerateId();

View file

@ -1,6 +1,8 @@
using System;
namespace Ryujinx.OsHle.Handles namespace Ryujinx.OsHle.Handles
{ {
class HSessionObj : HSession class HSessionObj : HSession, IDisposable
{ {
public object Obj { get; private set; } public object Obj { get; private set; }
@ -8,5 +10,21 @@ namespace Ryujinx.OsHle.Handles
{ {
this.Obj = Obj; 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();
}
}
}
} }
} }

View file

@ -212,7 +212,7 @@ namespace Ryujinx.OsHle.Ipc
Ns.Os.Handles.ReplaceData(HndId, Dom); Ns.Os.Handles.ReplaceData(HndId, Dom);
return FillResponse(Response, 0, Dom.GenertateObjectId(Dom)); return FillResponse(Response, 0, Dom.GenerateObjectId(Dom));
} }
private static IpcMessage IpcDuplicateSessionEx( private static IpcMessage IpcDuplicateSessionEx(

View file

@ -9,7 +9,7 @@ namespace Ryujinx.OsHle.Objects
{ {
if (Context.Session is HDomain Dom) if (Context.Session is HDomain Dom)
{ {
Context.Response.ResponseObjIds.Add(Dom.GenertateObjectId(Obj)); Context.Response.ResponseObjIds.Add(Dom.GenerateObjectId(Obj));
} }
else else
{ {