]> git.sesse.net Git - vlc/commitdiff
Cleanup IDisposable support
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 21 Feb 2009 18:29:18 +0000 (20:29 +0200)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 21 Feb 2009 18:29:18 +0000 (20:29 +0200)
bindings/cil/src/exception.cs
bindings/cil/src/marshal.cs

index 2b3118fa435a232a4de5f896d75f93374ba884f6..b8b3a8861be8c3efc3aaf3c7787bb6aad780d587 100644 (file)
@@ -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);
         }
index 9d37394900f008cc0296f8ceb57c1ae6377ca144..2135acaf9c28545cc5b2b313df5d1b0496f665eb 100644 (file)
@@ -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;
         }
     };
 };