nemo r96 - trunk/gtk



Author: arj
Date: Mon Mar 10 20:41:47 2008
New Revision: 96
URL: http://svn.gnome.org/viewvc/nemo?rev=96&view=rev

Log:
Plug big memory leak in day view



Modified:
   trunk/gtk/DisplayItem.cs

Modified: trunk/gtk/DisplayItem.cs
==============================================================================
--- trunk/gtk/DisplayItem.cs	(original)
+++ trunk/gtk/DisplayItem.cs	Mon Mar 10 20:41:47 2008
@@ -109,7 +109,7 @@
 			Gtk.Alignment picture_alignment = new Gtk.Alignment(0.5f, 0.5f, 0, 0);
 
 			picture_alignment.Add(picture_resizer);
-
+			
 			GtkCommon.show_hand_and_tooltip(picture_wrapper, Mono.Unix.Catalog.GetString("Open"));
 
 			box.PackStart(picture_alignment, true, true, 3);
@@ -136,6 +136,7 @@
 				box.PackStart(tmp, false, true, 3);
 
 			} else {
+
 				Gtk.Label title = new Gtk.Label();
 				title.Markup = "<b>" + item.name(35) + "</b>";
 			
@@ -280,42 +281,44 @@
 			} 
 			else
 			{
-				Gnome.ThumbnailFactory factory = new Gnome.ThumbnailFactory(Gnome.ThumbnailSize.Normal);
-
-				System.DateTime mtime = System.IO.File.GetLastWriteTime(item.path);
+				using (Gnome.ThumbnailFactory factory = new Gnome.ThumbnailFactory(Gnome.ThumbnailSize.Normal)) {
 
-				Gnome.Vfs.Uri vfs_uri = new Gnome.Vfs.Uri(item.path);
-				string mime = vfs_uri.MimeType.Name;
+					System.DateTime mtime = System.IO.File.GetLastWriteTime(item.path);
 
-				if (factory.HasValidFailedThumbnail(uri, mtime)) {
-					pic_path = "/usr/share/nemo/no-preview.png";
-					return; 
-				}
-
-				System.Console.WriteLine("trying to thumbnail {0}", item.path);
+					using (Gnome.Vfs.Uri vfs_uri = new Gnome.Vfs.Uri(item.path)) {
+						string mime = vfs_uri.MimeType.Name;
 
-				System.Console.WriteLine(mime);
-
-				if (factory.CanThumbnail(uri, mime, mtime)) 
-				{
-					Gdk.Pixbuf thumb = factory.GenerateThumbnail(uri, mime);
-					if (thumb == null) 
-					{
-						System.Console.WriteLine("failed to generate thumbnail");
-						factory.CreateFailedThumbnail(uri, mtime);
-						pic_path = "/usr/share/nemo/no-preview.png";
-					} 
-					else {
-						factory.SaveThumbnail(thumb, uri, mtime);
-						set_picture_path(); // use the new picture
+						if (factory.HasValidFailedThumbnail(uri, mtime)) {
+							pic_path = "/usr/share/nemo/no-preview.png";
+							return; 
+						}
+
+						System.Console.WriteLine("trying to thumbnail {0}", item.path);
+
+						System.Console.WriteLine(mime);
+
+						if (factory.CanThumbnail(uri, mime, mtime)) 
+						{
+							Gdk.Pixbuf thumb = factory.GenerateThumbnail(uri, mime);
+							if (thumb == null) 
+							{
+								System.Console.WriteLine("failed to generate thumbnail");
+								factory.CreateFailedThumbnail(uri, mtime);
+								pic_path = "/usr/share/nemo/no-preview.png";
+							} 
+							else {
+								factory.SaveThumbnail(thumb, uri, mtime);
+								set_picture_path(); // use the new picture
+							}
+						}
+						else
+						{
+							factory.CreateFailedThumbnail(uri, mtime);
+							System.Console.WriteLine("Can't thumbnail");
+							pic_path = "/usr/share/nemo/no-preview.png";
+						}
 					}
 				}
-				else
-				{
-					factory.CreateFailedThumbnail(uri, mtime);
-					System.Console.WriteLine("Can't thumbnail");
-					pic_path = "/usr/share/nemo/no-preview.png";
-				}
 			}
 		}
 	}



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