[gbrainy] Dispose FontDescription object
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy] Dispose FontDescription object
- Date: Sun, 8 May 2011 08:14:41 +0000 (UTC)
commit 02b5f26342347d481eb8153e4e2e426786e55866
Author: Jordi Mas <jmas softcatala org>
Date: Sun May 8 10:14:09 2011 +0200
Dispose FontDescription object
src/Core/Libraries/CairoContext.cs | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/src/Core/Libraries/CairoContext.cs b/src/Core/Libraries/CairoContext.cs
index 8a706e5..1f158e9 100644
--- a/src/Core/Libraries/CairoContext.cs
+++ b/src/Core/Libraries/CairoContext.cs
@@ -32,6 +32,7 @@ namespace gbrainy.Core.Libraries
public class CairoContext : Cairo.Context
{
Pango.Layout layout;
+ FontDescription font_description;
double font_size;
const double def_linespace = 0.018;
const double width_margin = 0.04;
@@ -42,7 +43,7 @@ namespace gbrainy.Core.Libraries
// We do not honor DPI settings or font sizes (just font name)
// User should resize the window
- layout.FontDescription = widget.PangoContext.FontDescription.Copy ();
+ font_description = layout.FontDescription = widget.PangoContext.FontDescription.Copy ();
FontLineSpace = def_linespace;
}
@@ -50,7 +51,7 @@ namespace gbrainy.Core.Libraries
public CairoContext (Cairo.Surface s, string font, int dpis) : base (s)
{
layout = Pango.CairoHelper.CreateLayout (this);
- layout.FontDescription = FontDescription.FromString (font);
+ font_description = layout.FontDescription = FontDescription.FromString (font);
if (dpis > 0) {
Pango.Context c = layout.Context;
@@ -65,7 +66,10 @@ namespace gbrainy.Core.Libraries
if (String.IsNullOrEmpty (value) == true)
return;
- layout.FontDescription = Pango.FontDescription.FromString (value);
+ if (font_description != null)
+ font_description.Dispose ();
+
+ font_description = layout.FontDescription = Pango.FontDescription.FromString (value);
}
}
@@ -78,6 +82,9 @@ namespace gbrainy.Core.Libraries
protected override void Dispose (bool disposing)
{
layout.Dispose ();
+
+ if (font_description != null)
+ font_description.Dispose ();
}
private void UpdateFontSize ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]