[banshee] Properly dispose FontDescriptions



commit d4440eb93be8f09ca18f15d788ca0aa9fe7022f6
Author: Alexander Kojevnikov <alexander kojevnikov com>
Date:   Mon Mar 15 09:09:58 2010 +1100

    Properly dispose FontDescriptions
    
    Pango.Layout.FontDescription setter and Gtk.Widget.ModifyFont()
    internally create copies of FDs and auto-dispose them. No need
    to create copies ourselves, they wouldn't be disposed.

 .../Banshee.Collection.Gui/ColumnCellAlbum.cs      |    3 +--
 .../Banshee.Widgets/Banshee.Widgets/SearchEntry.cs |    2 +-
 .../Banshee.Widgets/StreamPositionLabel.cs         |    3 +--
 .../Banshee.InternetArchive/HomeView.cs            |    1 +
 .../Banshee.Podcasting.Gui/ColumnCellPodcast.cs    |    3 +--
 .../Hyena.Gui/Hyena.Gui/CairoExtensions.cs         |    2 +-
 .../Hyena.Gui/Hyena.Widgets/RatingEntry.cs         |    1 +
 7 files changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs
index 2d0108c..d7ec9e9 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs
@@ -155,7 +155,7 @@ namespace Banshee.Collection.Gui
             int text_w, text_h;
 
             Pango.Layout layout = new Pango.Layout (widget.PangoContext);
-            layout.FontDescription = widget.PangoContext.FontDescription.Copy ();
+            layout.FontDescription = widget.PangoContext.FontDescription;
 
             layout.FontDescription.Weight = Pango.Weight.Bold;
             layout.SetText ("W");
@@ -169,7 +169,6 @@ namespace Banshee.Collection.Gui
             layout.GetPixelSize (out text_w, out text_h);
             height += text_h;
 
-            layout.FontDescription.Dispose ();
             layout.Dispose ();
 
             return (height < image_size ? image_size : height) + 6;
diff --git a/src/Core/Banshee.Widgets/Banshee.Widgets/SearchEntry.cs b/src/Core/Banshee.Widgets/Banshee.Widgets/SearchEntry.cs
index fc388cf..cb5c8b4 100644
--- a/src/Core/Banshee.Widgets/Banshee.Widgets/SearchEntry.cs
+++ b/src/Core/Banshee.Widgets/Banshee.Widgets/SearchEntry.cs
@@ -506,7 +506,7 @@ namespace Banshee.Widgets
 
                 if (layout == null) {
                     layout = new Pango.Layout(PangoContext);
-                    layout.FontDescription = PangoContext.FontDescription.Copy();
+                    layout.FontDescription = PangoContext.FontDescription;
                 }
 
                 int width, height;
diff --git a/src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs b/src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs
index 15106fd..e8e3748 100644
--- a/src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs
+++ b/src/Core/Banshee.Widgets/Banshee.Widgets/StreamPositionLabel.cs
@@ -67,12 +67,11 @@ namespace Banshee.Widgets
         private void BuildLayouts ()
         {
             if (layout != null) {
-                layout.FontDescription.Dispose ();
                 layout.Dispose ();
             }
 
             layout = new Pango.Layout (PangoContext);
-            layout.FontDescription = PangoContext.FontDescription.Copy ();
+            layout.FontDescription = PangoContext.FontDescription;
             layout.Ellipsize = Pango.EllipsizeMode.None;
         }
 
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/HomeView.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/HomeView.cs
index 52bfc9f..43fdfff 100644
--- a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/HomeView.cs
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/HomeView.cs
@@ -104,6 +104,7 @@ namespace Banshee.InternetArchive
             var font = entry.InnerEntry.Style.FontDescription.Copy ();
             font.Size = (int) (font.Size * Pango.Scale.XLarge);
             entry.InnerEntry.ModifyFont (font);
+            font.Dispose ();
 
             var button = new Hyena.Widgets.ImageButton (Catalog.GetString ("_Go"), Stock.Find);
             entry.Activated += (o, a) => { button.Activate (); };
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/ColumnCellPodcast.cs b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/ColumnCellPodcast.cs
index 7f94010..f81266f 100644
--- a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/ColumnCellPodcast.cs
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/ColumnCellPodcast.cs
@@ -150,7 +150,7 @@ namespace Banshee.Podcasting.Gui
             int text_w, text_h;
 
             Pango.Layout layout = new Pango.Layout (widget.PangoContext);
-            layout.FontDescription = widget.PangoContext.FontDescription.Copy ();
+            layout.FontDescription = widget.PangoContext.FontDescription;
 
             layout.FontDescription.Weight = Pango.Weight.Bold;
             layout.SetText ("W");
@@ -164,7 +164,6 @@ namespace Banshee.Podcasting.Gui
             layout.GetPixelSize (out text_w, out text_h);
             height += text_h;
 
-            layout.FontDescription.Dispose ();
             layout.Dispose ();
 
             return (height < image_size ? image_size : height) + 6;
diff --git a/src/Libraries/Hyena.Gui/Hyena.Gui/CairoExtensions.cs b/src/Libraries/Hyena.Gui/Hyena.Gui/CairoExtensions.cs
index 80c1b67..80cc29d 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Gui/CairoExtensions.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Gui/CairoExtensions.cs
@@ -51,7 +51,7 @@ namespace Hyena.Gui
         public static Pango.Layout CreateLayout (Gtk.Widget widget, Cairo.Context cairo_context)
         {
             Pango.Layout layout = PangoCairoHelper.CreateLayout (cairo_context);
-            layout.FontDescription = widget.PangoContext.FontDescription.Copy ();
+            layout.FontDescription = widget.PangoContext.FontDescription;
 
             double resolution = widget.Screen.Resolution;
             if (resolution != -1) {
diff --git a/src/Libraries/Hyena.Gui/Hyena.Widgets/RatingEntry.cs b/src/Libraries/Hyena.Gui/Hyena.Widgets/RatingEntry.cs
index 7356605..f6678a8 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Widgets/RatingEntry.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Widgets/RatingEntry.cs
@@ -496,6 +496,7 @@ namespace Hyena.Widgets
             Pango.FontDescription fd = entry3.PangoContext.FontDescription.Copy ();
             fd.Size = (int)(fd.Size * Pango.Scale.XXLarge);
             entry3.ModifyFont (fd);
+            fd.Dispose ();
             box.PackStart (entry3, true, true, 0);
 
             pbox.ShowAll ();



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