[f-spot] Always dispose ImageFile streams.



commit d39e4c9351c6203526bd16951dcc0c72fdb45dc6
Author: Ruben Vermeersch <ruben savanne be>
Date:   Sun Jun 13 14:24:41 2010 +0200

    Always dispose ImageFile streams.

 src/Imaging/ImageFile.cs |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/Imaging/ImageFile.cs b/src/Imaging/ImageFile.cs
index dab045a..c44b9c9 100644
--- a/src/Imaging/ImageFile.cs
+++ b/src/Imaging/ImageFile.cs
@@ -23,6 +23,7 @@ namespace FSpot {
 
 		static Hashtable name_table;
 		internal static Hashtable NameTable { get { return name_table; } }
+		Stream stream = null;
 		
 		public ImageFile (SafeUri uri)
 		{
@@ -36,10 +37,11 @@ namespace FSpot {
 		
 		protected Stream Open ()
 		{
+			if (stream != null)
+				throw new Exception ("Already open!");
 			Log.DebugFormat ("open uri = {0}", uri.ToString ());
-//			if (uri.IsFile)
-//				return new FileStream (uri.LocalPath, FileMode.Open);
-			return new GLib.GioStream (GLib.FileFactory.NewForUri (uri).Read (null));
+			stream = new GLib.GioStream (GLib.FileFactory.NewForUri (uri).Read (null));
+			return stream;
 		}
 
 		public virtual Stream PixbufStream ()
@@ -237,6 +239,8 @@ namespace FSpot {
 
 		public void Dispose ()
 		{
+			if (stream != null)
+				stream.Close ();
 			Close ();
 			System.GC.SuppressFinalize (this);
 		}



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