[banshee] [Gui.TrackEditor] Dispose of TagLib.File



commit 55859c2f0e502092cc5fa78f8163c8897210d5e9
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Sat Mar 20 17:47:44 2010 -0700

    [Gui.TrackEditor] Dispose of TagLib.File

 .../Banshee.Gui.TrackEditor/EditorTrackInfo.cs     |   32 ++++++-------------
 .../Banshee.Gui.TrackEditor/StatisticsPage.cs      |    3 +-
 2 files changed, 12 insertions(+), 23 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/EditorTrackInfo.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/EditorTrackInfo.cs
index 5667056..8a47154 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/EditorTrackInfo.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/EditorTrackInfo.cs
@@ -40,9 +40,6 @@ namespace Banshee.Gui.TrackEditor
 {
     public class EditorTrackInfo : TrackInfo
     {
-        private TagLib.File taglib_file;
-        private bool taglib_file_exists = true;
-
         public EditorTrackInfo (TrackInfo sourceTrack)
         {
             source_track = sourceTrack;
@@ -93,28 +90,19 @@ namespace Banshee.Gui.TrackEditor
             get { return source_track; }
         }
 
-        public TagLib.File TaglibFile {
-            get {
-                if (taglib_file != null) {
-                    return taglib_file;
-                } else if (!taglib_file_exists) {
-                    return null;
-                }
+        public TagLib.File GetTaglibFile ()
+        {
+            TagLib.File file = null;
 
-                try {
-                    taglib_file = StreamTagger.ProcessUri (Uri);
-                    if (taglib_file != null) {
-                        return taglib_file;
-                    }
-                } catch (Exception e) {
-                    if (Uri.Scheme == "file") {
-                        Hyena.Log.Exception ("Cannot load TagLib file", e);
-                    }
+            try {
+                file = StreamTagger.ProcessUri (Uri);
+            } catch (Exception e) {
+                if (Uri.Scheme == "file") {
+                    Hyena.Log.Exception ("Cannot load TagLib file", e);
                 }
-
-                taglib_file_exists = false;
-                return null;
             }
+
+            return file;
         }
     }
 }
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs
index 1072baf..8552df2 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui.TrackEditor/StatisticsPage.cs
@@ -152,7 +152,7 @@ namespace Banshee.Gui.TrackEditor
             model = null;
             CreateModel ();
 
-            TagLib.File file = track.TaglibFile;
+            TagLib.File file = track.GetTaglibFile ();
 
             if (track.Uri.IsLocalPath) {
                 string path = track.Uri.AbsolutePath;
@@ -201,6 +201,7 @@ namespace Banshee.Gui.TrackEditor
 
                 AddItem (Catalog.GetString ("Container Formats:"), file.TagTypes.ToString ());
                 AddSeparator ();
+                file.Dispose ();
             }
 
             AddItem (Catalog.GetString ("Imported On:"), track.DateAdded > DateTime.MinValue



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