[banshee] [gio] More FileInfo disposing



commit 4632be2932af09ae01f61e26e1bba61eee6dc6fa
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed Mar 17 15:47:11 2010 -0700

    [gio] More FileInfo disposing

 .../Banshee.Gio/Banshee.IO.Gio/Directory.cs        |   16 +++++++++++-----
 src/Backends/Banshee.Gio/Banshee.IO.Gio/File.cs    |   12 +++++++-----
 2 files changed, 18 insertions(+), 10 deletions(-)
---
diff --git a/src/Backends/Banshee.Gio/Banshee.IO.Gio/Directory.cs b/src/Backends/Banshee.Gio/Banshee.IO.Gio/Directory.cs
index bff49d4..a2283e7 100644
--- a/src/Backends/Banshee.Gio/Banshee.IO.Gio/Directory.cs
+++ b/src/Backends/Banshee.Gio/Banshee.IO.Gio/Directory.cs
@@ -119,9 +119,12 @@ namespace Banshee.IO.Gio
         {
             foreach (FileInfo file in dir.EnumerateChildren ("standard::type,standard::name", followSymlinks ? FileQueryInfoFlags.None : FileQueryInfoFlags.NofollowSymlinks, null)) {
                 if ((file.FileType & FileType.Regular) != 0) {
-                    yield return dir.Uri.AbsoluteUri + "/" + Uri.EscapeDataString (file.Name);
+                    var ret = dir.Uri.AbsoluteUri + "/" + Uri.EscapeDataString (file.Name);
+                    file.Dispose ();
+                    yield return ret;
+                } else {
+                    file.Dispose ();
                 }
-                file.Dispose ();
             }
         }
 
@@ -134,9 +137,12 @@ namespace Banshee.IO.Gio
         {
             foreach (FileInfo file in dir.EnumerateChildren ("standard::type,standard::name", followSymlinks ? FileQueryInfoFlags.None : FileQueryInfoFlags.NofollowSymlinks, null)) {
                 if ((file.FileType & FileType.Directory) != 0) {
-                    yield return dir.Uri.AbsoluteUri + "/" + Uri.EscapeDataString (file.Name);
+                    var ret = dir.Uri.AbsoluteUri + "/" + Uri.EscapeDataString (file.Name);
+                    file.Dispose ();
+                    yield return ret;
+                } else {
+                    file.Dispose ();
                 }
-                file.Dispose ();
             }
         }
 
@@ -146,4 +152,4 @@ namespace Banshee.IO.Gio
             dir.Move (FileFactory.NewForUri (to.AbsoluteUri), FileCopyFlags.None, null, null);
         }
     }
-}
+}
\ No newline at end of file
diff --git a/src/Backends/Banshee.Gio/Banshee.IO.Gio/File.cs b/src/Backends/Banshee.Gio/Banshee.IO.Gio/File.cs
index 74eb3de..b535c39 100644
--- a/src/Backends/Banshee.Gio/Banshee.IO.Gio/File.cs
+++ b/src/Backends/Banshee.Gio/Banshee.IO.Gio/File.cs
@@ -80,8 +80,9 @@ namespace Banshee.IO.Gio
         {
             try {
                 var file = FileFactory.NewForUri (uri.AbsoluteUri);
-                var file_info = file.QueryInfo ("standard::size", FileQueryInfoFlags.None, null);
-                return file_info.Size;
+                using (var file_info = file.QueryInfo ("standard::size", FileQueryInfoFlags.None, null)) {
+                    return file_info.Size;
+                }
             } catch {
                 return -1;
             }
@@ -90,8 +91,9 @@ namespace Banshee.IO.Gio
         public long GetModifiedTime (SafeUri uri)
         {
             var file = FileFactory.NewForUri (uri.AbsoluteUri);
-            var file_info = file.QueryInfo ("time::modified", FileQueryInfoFlags.None, null);
-            return (long) file_info.GetAttributeULong ("time::modified");
+            using (var file_info = file.QueryInfo ("time::modified", FileQueryInfoFlags.None, null)) {
+                return (long) file_info.GetAttributeULong ("time::modified");
+            }
         }
     }
-}
+}
\ No newline at end of file



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