[f-spot] fix leakage in softfocus too



commit 079ed482bb949df931e65377d14947c6642f0d3a
Author: Stephane Delcroix <stephane delcroix org>
Date:   Fri Nov 20 11:31:06 2009 +0100

    fix leakage in softfocus too

 src/Editors/SoftFocusEditor.cs |   49 ++++++++++++++++++++++-----------------
 src/SoftFocus.cs               |    2 +-
 2 files changed, 29 insertions(+), 22 deletions(-)
---
diff --git a/src/Editors/SoftFocusEditor.cs b/src/Editors/SoftFocusEditor.cs
index cd45136..8f63796 100644
--- a/src/Editors/SoftFocusEditor.cs
+++ b/src/Editors/SoftFocusEditor.cs
@@ -3,32 +3,37 @@
  *
  * Author(s)
  * 	Ruben Vermeersch <ruben savanne be>
+ *	Stephane Delcroix <stephane delcroix org>
  *
- * This is free software. See COPYING for details.
+ * Copyright (c) 2009 Stephane Delcroix
+ *
+ * This is open source software. See COPYING for details.
  */
 
+using System;
+using Mono.Unix;
 using Cairo;
+using Gdk;
+using Gtk;
 
 using FSpot.Widgets;
 
-using Gdk;
-using Gtk;
 
-using Mono.Unix;
 
-using System;
 
-namespace FSpot.Editors {
+namespace FSpot.Editors
+{
 	// TODO: This had a keybinding e. Maybe we should add it back, but did people even knew it?
 	class SoftFocusEditor : Editor
 	{
 		double radius;
 		Scale scale;
 
-		public SoftFocusEditor () : base (Catalog.GetString ("Soft Focus"), "filter-soft-focus") {
+		public SoftFocusEditor () : base (Catalog.GetString ("Soft Focus"), "filter-soft-focus")
+		{
 			// FIXME: need tooltip Catalog.GetString ("Create a soft focus visual effect")
 			HasSettings = true;
-        }
+		}
 
 		public override Widget ConfigurationWidget ()
 		{
@@ -52,19 +57,21 @@ namespace FSpot.Editors {
 		private Pixbuf ProcessImpl (Pixbuf input, Cms.Profile input_profile, bool fast) {
 			Pixbuf result;
 			using (ImageInfo info = new ImageInfo (input)) {
-				Widgets.SoftFocus soft = new Widgets.SoftFocus (info);
-				soft.Radius = radius;
-
-				MemorySurface surface = new MemorySurface (Format.Argb32,
-									   input.Width,
-									   input.Height);
-
-				Context ctx = new Context (surface);
-				soft.Apply (ctx, info.Bounds);
-				((IDisposable)ctx).Dispose ();
-
-				result = MemorySurface.CreatePixbuf (surface);
-				surface.Flush ();
+				using (Widgets.SoftFocus soft = new Widgets.SoftFocus (info)) {
+					soft.Radius = radius;
+	
+					using (MemorySurface surface = new MemorySurface (Format.Argb32,
+										   input.Width,
+										   input.Height)) {
+	
+						using (Context ctx = new Context (surface)) {
+							soft.Apply (ctx, info.Bounds);
+						}
+
+						result = MemorySurface.CreatePixbuf (surface);
+						surface.Flush ();
+					}
+				}
 			}
 			return result;
 		}
diff --git a/src/SoftFocus.cs b/src/SoftFocus.cs
index 7291d5a..7cb54f2 100644
--- a/src/SoftFocus.cs
+++ b/src/SoftFocus.cs
@@ -12,7 +12,7 @@ using System.Runtime.InteropServices;
 
 namespace FSpot.Widgets {
 
-	public class SoftFocus {
+	public class SoftFocus : IDisposable {
 
 		ImageInfo info;
 		double radius;



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