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:
authorMiguel de Icaza <miguel@gnome.org>2007-07-08 00:01:40 +0400
committerMiguel de Icaza <miguel@gnome.org>2007-07-08 00:01:40 +0400
commitcaae027f2f3894704b158cb92d8e6e5a830e8749 (patch)
treef688b33faeb9a70feda66b81f7cb08b92b6c997a /mcs/class/Mono.Cairo
parent17e4775057644dd28f56cff30ac68b0dffb78042 (diff)
Implement properly the dispose patternw where possible
svn path=/trunk/mcs/; revision=81575
Diffstat (limited to 'mcs/class/Mono.Cairo')
-rw-r--r--mcs/class/Mono.Cairo/Mono.Cairo/FontFace.cs9
-rw-r--r--mcs/class/Mono.Cairo/Mono.Cairo/Pattern.cs22
2 files changed, 24 insertions, 7 deletions
diff --git a/mcs/class/Mono.Cairo/Mono.Cairo/FontFace.cs b/mcs/class/Mono.Cairo/Mono.Cairo/FontFace.cs
index 684bf0f80e7..a7adbd9339a 100644
--- a/mcs/class/Mono.Cairo/Mono.Cairo/FontFace.cs
+++ b/mcs/class/Mono.Cairo/Mono.Cairo/FontFace.cs
@@ -54,11 +54,18 @@ namespace Cairo
// font_face here, the programmer must do this with IDisposable.Dispose
Console.Error.WriteLine ("Programmer forgot to call Dispose on the FontFace");
+ Dispose (false);
}
void IDisposable.Dispose ()
{
- NativeMethods.cairo_font_face_destroy (handle);
+ Dispose (true);
+ }
+
+ protected virtual void Dispose (bool disposing)
+ {
+ if (disposing)
+ NativeMethods.cairo_font_face_destroy (handle);
handle = IntPtr.Zero;
GC.SuppressFinalize (this);
}
diff --git a/mcs/class/Mono.Cairo/Mono.Cairo/Pattern.cs b/mcs/class/Mono.Cairo/Mono.Cairo/Pattern.cs
index a4ee9daa533..80a180ee332 100644
--- a/mcs/class/Mono.Cairo/Mono.Cairo/Pattern.cs
+++ b/mcs/class/Mono.Cairo/Mono.Cairo/Pattern.cs
@@ -76,9 +76,6 @@ namespace Cairo {
~Pattern ()
{
- lock (patterns){
- patterns.Remove (this);
- }
}
[Obsolete ("Use the SurfacePattern constructor")]
@@ -92,14 +89,27 @@ namespace Cairo {
NativeMethods.cairo_pattern_reference (pattern);
}
- public void Dispose ()
+ void IDisposable.Dispose ()
+ {
+ Dispose (true);
+ }
+
+ protected virtual void Dispose (bool disposing)
{
- Destroy ();
+ if (disposing)
+ Destroy ();
+ GC.SuppressFinalize (this);
}
public void Destroy ()
{
- NativeMethods.cairo_pattern_destroy (pattern);
+ if (pattern != IntPtr.Zero){
+ NativeMethods.cairo_pattern_destroy (pattern);
+ pattern = IntPtr.Zero;
+ }
+ lock (patterns){
+ patterns.Remove (this);
+ }
}
public Status Status