From 8416c5ff45d9c99ecd53e1d088bece8808cb6bb4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sat, 21 Feb 2009 20:29:18 +0200 Subject: [PATCH] Cleanup IDisposable support --- bindings/cil/src/exception.cs | 17 +++++++++++------ bindings/cil/src/marshal.cs | 16 ++++++++++++++-- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/bindings/cil/src/exception.cs b/bindings/cil/src/exception.cs index 2b3118fa43..b8b3a8861b 100644 --- a/bindings/cil/src/exception.cs +++ b/bindings/cil/src/exception.cs @@ -105,12 +105,6 @@ namespace VideoLAN.LibVLC private static extern void Init (NativeException e); [DllImport ("libvlc.dll", EntryPoint="libvlc_exception_clear")] private static extern void Clear (NativeException e); - /*[DllImport ("libvlc.dll", - EntryPoint="libvlc_exception_raised")] - private static extern int Raised (NativeException e);*/ - [DllImport ("libvlc.dll", - EntryPoint="libvlc_exception_get_message")] - private static extern IntPtr GetMessage (NativeException e); public NativeException () { @@ -142,6 +136,17 @@ namespace VideoLAN.LibVLC /** IDisposable implementation. */ public void Dispose () + { + Dispose (true); + GC.SuppressFinalize (this); + } + + ~NativeException () + { + Dispose (false); + } + + private void Dispose (bool disposing) { Clear (this); } diff --git a/bindings/cil/src/marshal.cs b/bindings/cil/src/marshal.cs index 9d37394900..2135acaf9c 100644 --- a/bindings/cil/src/marshal.cs +++ b/bindings/cil/src/marshal.cs @@ -97,8 +97,20 @@ namespace VideoLAN.LibVLC */ public void Dispose () { - ex.Dispose (); - handle.Close (); + Dispose (true); + GC.SuppressFinalize (this); + } + + protected virtual void Dispose (bool disposing) + { + if (disposing) + { + ex.Dispose (); + if (handle != null) + handle.Close (); + } + ex = null; + handle = null; } }; }; -- 2.39.2