diff options
author | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2016-09-18 15:58:23 +0300 |
---|---|---|
committer | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2016-09-18 16:32:32 +0300 |
commit | 4d55db6c206cb8436d438a7b5fe05c1bdcd5e8e3 (patch) | |
tree | 2ec7b220cc406353aeef328cb10ada102f71f12b /main/src/core/MonoDevelop.Ide/MonoDevelop.Components.PropertyGrid.Editors | |
parent | 3c7cbdb330e97e846a2a7f03f6f1a5a09e1a0148 (diff) |
[Ide] Fix leak Pango.Layout in FlagsEditorCell
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Components.PropertyGrid.Editors')
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Components.PropertyGrid.Editors/FlagsEditorCell.cs | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.PropertyGrid.Editors/FlagsEditorCell.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.PropertyGrid.Editors/FlagsEditorCell.cs index 1e1a2c1a2c..272cb84f54 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.PropertyGrid.Editors/FlagsEditorCell.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.PropertyGrid.Editors/FlagsEditorCell.cs @@ -94,30 +94,31 @@ namespace MonoDevelop.Components.PropertyGrid.PropertyEditors { InitializeStyle (Container); var container = (Widget)Container; - var layout = new Pango.Layout (container.PangoContext); - layout.Width = -1; - layout.FontDescription = FontService.SansFont.CopyModified (Ide.Gui.Styles.FontScale11); - - ulong value = Convert.ToUInt64 (Value); - int dy = 2; - foreach (var val in values) { - ulong uintVal = Convert.ToUInt64 (val); - Gtk.ShadowType sh = (value & uintVal) != 0 ? Gtk.ShadowType.In : Gtk.ShadowType.Out; - if (value == 0 && uintVal == 0) - sh = Gtk.ShadowType.In; - int s = indicatorSize - 1; - Gtk.Style.PaintCheck (style, window, state, sh, bounds, Container, "checkbutton", bounds.X + indicatorSpacing - 1, bounds.Y + dy, s, s); - - layout.SetText (val.ToString ()); - int tw, th; - layout.GetPixelSize (out tw, out th); - ctx.Save (); - ctx.SetSourceColor (container.Style.Text (state).ToCairoColor ()); - ctx.MoveTo (bounds.X + indicatorSize + indicatorSpacing, dy + bounds.Y + ((indicatorSize - th) / 2)); - Pango.CairoHelper.ShowLayout (ctx, layout); - ctx.Restore (); - - dy += indicatorSize + CheckSpacing; + using (var layout = new Pango.Layout (container.PangoContext)) {
+ layout.Width = -1;
+ layout.FontDescription = FontService.SansFont.CopyModified (Ide.Gui.Styles.FontScale11);
+
+ ulong value = Convert.ToUInt64 (Value);
+ int dy = 2;
+ foreach (var val in values) {
+ ulong uintVal = Convert.ToUInt64 (val);
+ Gtk.ShadowType sh = (value & uintVal) != 0 ? Gtk.ShadowType.In : Gtk.ShadowType.Out;
+ if (value == 0 && uintVal == 0)
+ sh = Gtk.ShadowType.In;
+ int s = indicatorSize - 1;
+ Gtk.Style.PaintCheck (style, window, state, sh, bounds, Container, "checkbutton", bounds.X + indicatorSpacing - 1, bounds.Y + dy, s, s);
+
+ layout.SetText (val.ToString ());
+ int tw, th;
+ layout.GetPixelSize (out tw, out th);
+ ctx.Save ();
+ ctx.SetSourceColor (container.Style.Text (state).ToCairoColor ());
+ ctx.MoveTo (bounds.X + indicatorSize + indicatorSpacing, dy + bounds.Y + ((indicatorSize - th) / 2));
+ Pango.CairoHelper.ShowLayout (ctx, layout);
+ ctx.Restore ();
+
+ dy += indicatorSize + CheckSpacing; + } } } else { base.Render (window, ctx, bounds, state); |