Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hutchinson <m.j.hutchinson@gmail.com>2013-03-06 09:35:46 +0400
committerMichael Hutchinson <m.j.hutchinson@gmail.com>2013-06-20 02:37:25 +0400
commit7085bed36ef3742d74cd34806b0d5dcf4d444052 (patch)
tree00e36e109d50df3c37d50887fe789c9fcd12abfa /mcs/class/Mono.Cairo
parent0bb971d513368fd0912f90e1ea32790eb0e22fd0 (diff)
[Mono.Cairo] Clean up Region's Dispose/ctor
Diffstat (limited to 'mcs/class/Mono.Cairo')
-rw-r--r--mcs/class/Mono.Cairo/Mono.Cairo/Region.cs32
1 files changed, 22 insertions, 10 deletions
diff --git a/mcs/class/Mono.Cairo/Mono.Cairo/Region.cs b/mcs/class/Mono.Cairo/Mono.Cairo/Region.cs
index e3b3eb1f83c..cd0ba33fde2 100644
--- a/mcs/class/Mono.Cairo/Mono.Cairo/Region.cs
+++ b/mcs/class/Mono.Cairo/Mono.Cairo/Region.cs
@@ -47,11 +47,7 @@ namespace Cairo
get { return handle; }
}
- ~Region ()
- {
- Console.WriteLine ("Cairo.Region finalizer reached - developer must dispose regions manually to avoid leakage due to thread-safety concerns.");
- }
-
+ [Obsolete]
public Region (IntPtr handle) : this (handle, false) {}
public Region (IntPtr handle, bool owned)
@@ -59,11 +55,12 @@ namespace Cairo
this.handle = handle;
if (!owned)
NativeMethods.cairo_region_reference (handle);
+ if (CairoDebug.Enabled)
+ CairoDebug.OnAllocated (handle);
}
- public Region ()
+ public Region () : this (NativeMethods.cairo_region_create () , true)
{
- handle = NativeMethods.cairo_region_create ();
}
public Region (RectangleInt rect)
@@ -81,14 +78,29 @@ namespace Cairo
return new Region (NativeMethods.cairo_region_copy (Handle), true);
}
+ ~Region ()
+ {
+ Dispose (false);
+ }
+
public void Dispose ()
{
- if (handle != IntPtr.Zero)
- NativeMethods.cairo_region_destroy (Handle);
- handle = IntPtr.Zero;
+ Dispose (true);
GC.SuppressFinalize (this);
}
+ protected virtual void Dispose (bool disposing)
+ {
+ if (!disposing || CairoDebug.Enabled)
+ CairoDebug.OnDisposed<Region> (handle, disposing);
+
+ if (!disposing|| handle == IntPtr.Zero)
+ return;
+
+ NativeMethods.cairo_region_destroy (Handle);
+ handle = IntPtr.Zero;
+ }
+
public override bool Equals (object obj)
{
return (obj is Region) && NativeMethods.cairo_region_equal (Handle, (obj as Region).Handle);