[f-spot] Avoid leaking in Strighten Editor



commit e5f5b1103d733257efdf746e8d50e6e4c8957876
Author: Stephane Delcroix <stephane delcroix org>
Date:   Thu Nov 19 21:22:17 2009 +0100

    Avoid leaking in Strighten Editor
    
    Dispose the IDisposables. fixes bgo #602390

 src/Editors/TiltEditor.cs |   45 +++++++++++++++++++++++----------------------
 1 files changed, 23 insertions(+), 22 deletions(-)
---
diff --git a/src/Editors/TiltEditor.cs b/src/Editors/TiltEditor.cs
index bda5826..f14d817 100644
--- a/src/Editors/TiltEditor.cs
+++ b/src/Editors/TiltEditor.cs
@@ -1,24 +1,26 @@
 /*
- * TiltEditor.cs
+ * FSpot.Editors.TiltEditor.cs
  *
  * Author(s)
  * 	Ruben Vermeersch <ruben savanne be>
+ *	Stephane Delcroix <stephane delcroix org>
  *
+ * Copyright (c) 2009 Stephane Delcroix
+ * 
  * This is free software. See COPYING for details.
  */
 
-using Cairo;
-
-using FSpot.Widgets;
+using System;
+using Mono.Unix;
 
 using Gdk;
 using Gtk;
+using Cairo;
 
-using Mono.Unix;
-
-using System;
+using FSpot.Widgets;
 
-namespace FSpot.Editors {
+namespace FSpot.Editors
+{
 	// TODO: there were keybindings (left/right) to adjust tilt, maybe they should be added back.
 	class TiltEditor : Editor
 	{
@@ -52,22 +54,21 @@ namespace FSpot.Editors {
 		private Pixbuf ProcessImpl (Pixbuf input, Cms.Profile input_profile, bool fast) {
 			Pixbuf result;
 			using (ImageInfo info = new ImageInfo (input)) {
-				MemorySurface surface = new MemorySurface (Format.Argb32,
+				using (MemorySurface surface = new MemorySurface (Format.Argb32,
 									   input.Width,
-									   input.Height);
-
-				Context ctx = new Context (surface);
-				ctx.Matrix = info.Fill (info.Bounds, angle);
-				SurfacePattern p = new SurfacePattern (info.Surface);
-				if (fast) {
-					p.Filter =  Filter.Fast;
+									   input.Height)) {
+					using (Context ctx = new Context (surface)) {
+						ctx.Matrix = info.Fill (info.Bounds, angle);
+						using (SurfacePattern p = new SurfacePattern (info.Surface)) {
+							if (fast) 
+								p.Filter =  Filter.Fast;
+							ctx.Source = p;
+							ctx.Paint ();
+						}
+						result = MemorySurface.CreatePixbuf (surface);
+						surface.Flush ();
+					}
 				}
-				ctx.Source = p;
-				ctx.Paint ();
-				((IDisposable)ctx).Dispose ();
-				p.Destroy ();
-				result = MemorySurface.CreatePixbuf (surface);
-				surface.Flush ();
 			}
 			return result;
 		}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]