[banshee] [grid] Fix a memleak (bgo#612688)
- From: Alexander Kojevnikov <alexk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [grid] Fix a memleak (bgo#612688)
- Date: Sun, 14 Mar 2010 10:01:08 +0000 (UTC)
commit dea249e8a6532b69d9a0364c2a64a47e68a63267
Author: Alexander Kojevnikov <alexander kojevnikov com>
Date: Sun Mar 14 20:41:47 2010 +1100
[grid] Fix a memleak (bgo#612688)
* We don't really need a new Pango.Layout - skip its creation
* We don't need a new FontDescription copy either, let's just restore
its Size like we already do in Render()
What was really causing the leak is the assignment of the newly created
FontDescription copy to Layout.FontDescription. The setter creates yet
another copy behind the scenes, leaving our FD undisposed.
There is still a small leak in Measure(), it looks like
MeasureTextHeight() is responsible. Will investigate this later.
.../Banshee.Collection.Gui/DataViewChildAlbum.cs | 21 ++++++++++---------
1 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DataViewChildAlbum.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DataViewChildAlbum.cs
index ba1cec1..bd22f7f 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DataViewChildAlbum.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DataViewChildAlbum.cs
@@ -219,17 +219,18 @@ namespace Banshee.Collection.Gui
{
var widget = ParentLayout.View;
- using (var layout = new Pango.Layout (widget.PangoContext) {
- FontDescription = widget.PangoContext.FontDescription.Copy ()
- }) {
- layout.FontDescription.Weight = Pango.Weight.Bold;
- first_line_allocation.Height = layout.FontDescription.MeasureTextHeight (widget.PangoContext);
+ var fd = widget.PangoContext.FontDescription;
+ int normal_size = fd.Size;
- layout.FontDescription.Weight = Pango.Weight.Normal;
- layout.FontDescription.Size = (int)(layout.FontDescription.Size * Pango.Scale.Small);
- layout.FontDescription.Style = Pango.Style.Italic;
- second_line_allocation.Height = layout.FontDescription.MeasureTextHeight (widget.PangoContext);
- }
+ fd.Weight = Pango.Weight.Bold;
+ first_line_allocation.Height = fd.MeasureTextHeight (widget.PangoContext);
+
+ fd.Weight = Pango.Weight.Normal;
+ fd.Size = (int)(fd.Size * Pango.Scale.Small);
+ fd.Style = Pango.Style.Italic;
+ second_line_allocation.Height = fd.MeasureTextHeight (widget.PangoContext);
+
+ fd.Size = normal_size;
double width, height;
double text_height = first_line_allocation.Height + second_line_allocation.Height;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]